~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavformat/mpegenc.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
#include "libavutil/fifo.h"
 
23
#include "libavutil/log.h"
 
24
#include "libavutil/mathematics.h"
 
25
#include "libavutil/opt.h"
23
26
#include "libavcodec/put_bits.h"
24
27
#include "avformat.h"
 
28
#include "internal.h"
25
29
#include "mpeg.h"
26
30
 
27
31
#define MAX_PAYLOAD_SIZE 4096
55
59
} StreamInfo;
56
60
 
57
61
typedef struct {
 
62
    const AVClass *class;
58
63
    int packet_size; /* required packet size */
59
64
    int packet_number;
60
65
    int pack_header_freq;     /* frequency (in packets^-1) at which we send pack headers */
73
78
    double vcd_padding_bitrate; //FIXME floats
74
79
    int64_t vcd_padding_bytes_written;
75
80
 
 
81
    int preload;
76
82
} MpegMuxContext;
77
83
 
78
84
extern AVOutputFormat ff_mpeg1vcd_muxer;
331
337
            goto fail;
332
338
        st->priv_data = stream;
333
339
 
334
 
        av_set_pts_info(st, 64, 1, 90000);
 
340
        avpriv_set_pts_info(st, 64, 1, 90000);
335
341
 
336
342
        switch(st->codec->codec_type) {
337
343
        case AVMEDIA_TYPE_AUDIO:
415
421
            video_bitrate += codec_rate;
416
422
    }
417
423
 
 
424
#if FF_API_MUXRATE
418
425
    if(ctx->mux_rate){
419
426
        s->mux_rate= (ctx->mux_rate + (8 * 50) - 1) / (8 * 50);
420
 
    } else {
 
427
    } else
 
428
#endif
 
429
    if (!s->mux_rate) {
421
430
        /* we increase slightly the bitrate to take into account the
422
431
           headers. XXX: compute it exactly */
423
 
        bitrate += bitrate*5/100;
 
432
        bitrate += bitrate / 20;
424
433
        bitrate += 10000;
425
434
        s->mux_rate = (bitrate + (8 * 50) - 1) / (8 * 50);
426
435
    }
1151
1160
    StreamInfo *stream = st->priv_data;
1152
1161
    int64_t pts, dts;
1153
1162
    PacketDesc *pkt_desc;
1154
 
    const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE);
 
1163
    int preload;
1155
1164
    const int is_iframe = st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (pkt->flags & AV_PKT_FLAG_KEY);
1156
1165
 
 
1166
#if FF_API_PRELOAD
 
1167
    if (ctx->preload)
 
1168
        s->preload = ctx->preload;
 
1169
#endif
 
1170
    preload = av_rescale(s->preload, 90000, AV_TIME_BASE);
 
1171
 
1157
1172
    pts= pkt->pts;
1158
1173
    dts= pkt->dts;
1159
1174
 
1226
1241
    return 0;
1227
1242
}
1228
1243
 
 
1244
#define OFFSET(x) offsetof(MpegMuxContext, x)
 
1245
#define E AV_OPT_FLAG_ENCODING_PARAM
 
1246
static const AVOption options[] = {
 
1247
    { "muxrate", NULL, OFFSET(mux_rate), AV_OPT_TYPE_INT, {0}, 0, INT_MAX, E },
 
1248
    { "preload", "Initial demux-decode delay in microseconds.", OFFSET(preload),  AV_OPT_TYPE_INT, {500000}, 0, INT_MAX, E},
 
1249
    { NULL },
 
1250
};
 
1251
 
 
1252
#define MPEGENC_CLASS(flavor)\
 
1253
static const AVClass flavor ## _class = {\
 
1254
    .class_name = #flavor " muxer",\
 
1255
    .item_name  = av_default_item_name,\
 
1256
    .version    = LIBAVUTIL_VERSION_INT,\
 
1257
    .option     = options,\
 
1258
};
 
1259
 
1229
1260
#if CONFIG_MPEG1SYSTEM_MUXER
 
1261
MPEGENC_CLASS(mpeg)
1230
1262
AVOutputFormat ff_mpeg1system_muxer = {
1231
 
    "mpeg",
1232
 
    NULL_IF_CONFIG_SMALL("MPEG-1 System format"),
1233
 
    "video/mpeg",
1234
 
    "mpg,mpeg",
1235
 
    sizeof(MpegMuxContext),
1236
 
    CODEC_ID_MP2,
1237
 
    CODEC_ID_MPEG1VIDEO,
1238
 
    mpeg_mux_init,
1239
 
    mpeg_mux_write_packet,
1240
 
    mpeg_mux_end,
 
1263
    .name              = "mpeg",
 
1264
    .long_name         = NULL_IF_CONFIG_SMALL("MPEG-1 System format"),
 
1265
    .mime_type         = "video/mpeg",
 
1266
    .extensions        = "mpg,mpeg",
 
1267
    .priv_data_size    = sizeof(MpegMuxContext),
 
1268
    .audio_codec       = CODEC_ID_MP2,
 
1269
    .video_codec       = CODEC_ID_MPEG1VIDEO,
 
1270
    .write_header      = mpeg_mux_init,
 
1271
    .write_packet      = mpeg_mux_write_packet,
 
1272
    .write_trailer     = mpeg_mux_end,
 
1273
    .priv_class        = &mpeg_class,
1241
1274
};
1242
1275
#endif
1243
1276
#if CONFIG_MPEG1VCD_MUXER
 
1277
MPEGENC_CLASS(vcd)
1244
1278
AVOutputFormat ff_mpeg1vcd_muxer = {
1245
 
    "vcd",
1246
 
    NULL_IF_CONFIG_SMALL("MPEG-1 System format (VCD)"),
1247
 
    "video/mpeg",
1248
 
    NULL,
1249
 
    sizeof(MpegMuxContext),
1250
 
    CODEC_ID_MP2,
1251
 
    CODEC_ID_MPEG1VIDEO,
1252
 
    mpeg_mux_init,
1253
 
    mpeg_mux_write_packet,
1254
 
    mpeg_mux_end,
 
1279
    .name              = "vcd",
 
1280
    .long_name         = NULL_IF_CONFIG_SMALL("MPEG-1 System format (VCD)"),
 
1281
    .mime_type         = "video/mpeg",
 
1282
    .priv_data_size    = sizeof(MpegMuxContext),
 
1283
    .audio_codec       = CODEC_ID_MP2,
 
1284
    .video_codec       = CODEC_ID_MPEG1VIDEO,
 
1285
    .write_header      = mpeg_mux_init,
 
1286
    .write_packet      = mpeg_mux_write_packet,
 
1287
    .write_trailer     = mpeg_mux_end,
 
1288
    .priv_class        = &vcd_class,
1255
1289
};
1256
1290
#endif
1257
1291
#if CONFIG_MPEG2VOB_MUXER
 
1292
MPEGENC_CLASS(vob)
1258
1293
AVOutputFormat ff_mpeg2vob_muxer = {
1259
 
    "vob",
1260
 
    NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"),
1261
 
    "video/mpeg",
1262
 
    "vob",
1263
 
    sizeof(MpegMuxContext),
1264
 
    CODEC_ID_MP2,
1265
 
    CODEC_ID_MPEG2VIDEO,
1266
 
    mpeg_mux_init,
1267
 
    mpeg_mux_write_packet,
1268
 
    mpeg_mux_end,
 
1294
    .name              = "vob",
 
1295
    .long_name         = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"),
 
1296
    .mime_type         = "video/mpeg",
 
1297
    .extensions        = "vob",
 
1298
    .priv_data_size    = sizeof(MpegMuxContext),
 
1299
    .audio_codec       = CODEC_ID_MP2,
 
1300
    .video_codec       = CODEC_ID_MPEG2VIDEO,
 
1301
    .write_header      = mpeg_mux_init,
 
1302
    .write_packet      = mpeg_mux_write_packet,
 
1303
    .write_trailer     = mpeg_mux_end,
 
1304
    .priv_class        = &vob_class,
1269
1305
};
1270
1306
#endif
1271
1307
 
1272
1308
/* Same as mpeg2vob_mux except that the pack size is 2324 */
1273
1309
#if CONFIG_MPEG2SVCD_MUXER
 
1310
MPEGENC_CLASS(svcd)
1274
1311
AVOutputFormat ff_mpeg2svcd_muxer = {
1275
 
    "svcd",
1276
 
    NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"),
1277
 
    "video/mpeg",
1278
 
    "vob",
1279
 
    sizeof(MpegMuxContext),
1280
 
    CODEC_ID_MP2,
1281
 
    CODEC_ID_MPEG2VIDEO,
1282
 
    mpeg_mux_init,
1283
 
    mpeg_mux_write_packet,
1284
 
    mpeg_mux_end,
 
1312
    .name              = "svcd",
 
1313
    .long_name         = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"),
 
1314
    .mime_type         = "video/mpeg",
 
1315
    .extensions        = "vob",
 
1316
    .priv_data_size    = sizeof(MpegMuxContext),
 
1317
    .audio_codec       = CODEC_ID_MP2,
 
1318
    .video_codec       = CODEC_ID_MPEG2VIDEO,
 
1319
    .write_header      = mpeg_mux_init,
 
1320
    .write_packet      = mpeg_mux_write_packet,
 
1321
    .write_trailer     = mpeg_mux_end,
 
1322
    .priv_class        = &svcd_class,
1285
1323
};
1286
1324
#endif
1287
1325
 
1288
1326
/*  Same as mpeg2vob_mux except the 'is_dvd' flag is set to produce NAV pkts */
1289
1327
#if CONFIG_MPEG2DVD_MUXER
 
1328
MPEGENC_CLASS(dvd)
1290
1329
AVOutputFormat ff_mpeg2dvd_muxer = {
1291
 
    "dvd",
1292
 
    NULL_IF_CONFIG_SMALL("MPEG-2 PS format (DVD VOB)"),
1293
 
    "video/mpeg",
1294
 
    "dvd",
1295
 
    sizeof(MpegMuxContext),
1296
 
    CODEC_ID_MP2,
1297
 
    CODEC_ID_MPEG2VIDEO,
1298
 
    mpeg_mux_init,
1299
 
    mpeg_mux_write_packet,
1300
 
    mpeg_mux_end,
 
1330
    .name              = "dvd",
 
1331
    .long_name         = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (DVD VOB)"),
 
1332
    .mime_type         = "video/mpeg",
 
1333
    .extensions        = "dvd",
 
1334
    .priv_data_size    = sizeof(MpegMuxContext),
 
1335
    .audio_codec       = CODEC_ID_MP2,
 
1336
    .video_codec       = CODEC_ID_MPEG2VIDEO,
 
1337
    .write_header      = mpeg_mux_init,
 
1338
    .write_packet      = mpeg_mux_write_packet,
 
1339
    .write_trailer     = mpeg_mux_end,
 
1340
    .priv_class        = &dvd_class,
1301
1341
};
1302
1342
#endif