diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-05-02 04:18:04 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-05-02 04:18:04 +0200 |
commit | d4b98d475f8abf9f05ebe91b3fce341aa4b902ee (patch) | |
tree | bc452a41fbc304d19ee058da006e9760cb160d6a /libavformat | |
parent | 8d8962ca3e95b1ce86ab505498e7cd3ec89fa996 (diff) | |
parent | 1a9f9f81b1244b952126bb65bc741b04d3534f81 (diff) | |
download | ffmpeg-d4b98d475f8abf9f05ebe91b3fce341aa4b902ee.tar.gz |
Merge commit '1a9f9f8' into oldabi
* commit '1a9f9f8': (98 commits)
Do not drop packets with no valid ->pos set as e.g. DV-in-AVI produces.
FFMPEG: support demuxer specific options. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
AVIDEC: use_odmc demuxer specific option. (mostly an exmaple for demuxer specific options) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
LAVFAPI: demuxer specific options. (someone please add doxy) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
output_example: use avformat_alloc_output_context() Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
LAVFAPI: avformat_alloc_output_context() / simplify usage of muxers. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
LAVF API: remove AVOutputFormat.set_parameters() the field is unused. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
CrystalHD: Add auto-detection of packed b-frame bug.
lavc: remove disabled avcodec_decode_video() code
Read the album_artist, grouping and lyrics metadata.
In libx264 wrapper, change wpredp to a codec specific option.
AMV: disable DR1 and don't override EMU_EDGE
lavf: inspect more frames for fps when container time base is coarse
Fix races in default av_log handler
flashsv2enc: regression test. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
vorbis: Replace sized int_fast integer types with plain int/unsigned.
Remove disabled non-optimized code variants.
bswap.h: Remove disabled code.
Remove some disabled printf debug cruft.
Replace more disabled printf() calls by av_dlog().
...
Conflicts:
libavcodec/options.c
libavcodec/qpeg.c
libavfilter/avfilter.h
libavformat/avformat.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/Makefile | 2 | ||||
-rw-r--r-- | libavformat/aiffdec.c | 4 | ||||
-rw-r--r-- | libavformat/avformat.h | 20 | ||||
-rw-r--r-- | libavformat/avidec.c | 24 | ||||
-rw-r--r-- | libavformat/avio.h | 6 | ||||
-rw-r--r-- | libavformat/caf.c | 57 | ||||
-rw-r--r-- | libavformat/caf.h | 3 | ||||
-rw-r--r-- | libavformat/cafdec.c | 2 | ||||
-rw-r--r-- | libavformat/ffmdec.c | 3 | ||||
-rw-r--r-- | libavformat/isom.c | 60 | ||||
-rw-r--r-- | libavformat/isom.h | 1 | ||||
-rw-r--r-- | libavformat/mov.c | 13 | ||||
-rw-r--r-- | libavformat/mpegts.c | 3 | ||||
-rw-r--r-- | libavformat/mpegtsenc.c | 2 | ||||
-rw-r--r-- | libavformat/network.h | 2 | ||||
-rw-r--r-- | libavformat/nutenc.c | 2 | ||||
-rw-r--r-- | libavformat/output-example.c | 27 | ||||
-rw-r--r-- | libavformat/utils.c | 73 |
18 files changed, 193 insertions, 111 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile index b892dbf6a7..e278136579 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -24,7 +24,7 @@ OBJS-$(CONFIG_AC3_DEMUXER) += ac3dec.o rawdec.o OBJS-$(CONFIG_AC3_MUXER) += rawenc.o OBJS-$(CONFIG_ADTS_MUXER) += adtsenc.o OBJS-$(CONFIG_AEA_DEMUXER) += aea.o pcm.o -OBJS-$(CONFIG_AIFF_DEMUXER) += aiffdec.o riff.o pcm.o caf.o +OBJS-$(CONFIG_AIFF_DEMUXER) += aiffdec.o riff.o pcm.o isom.o OBJS-$(CONFIG_AIFF_MUXER) += aiffenc.o riff.o OBJS-$(CONFIG_AMR_DEMUXER) += amr.o OBJS-$(CONFIG_AMR_MUXER) += amr.o diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index a3aecee0a8..cc2631448b 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -23,7 +23,7 @@ #include "avformat.h" #include "pcm.h" #include "aiff.h" -#include "caf.h" +#include "isom.h" #define AIFF 0 #define AIFF_C_VERSION1 0xA2805140 @@ -257,7 +257,7 @@ static int aiff_read_header(AVFormatContext *s, case MKTAG('C','H','A','N'): if (size < 12) return AVERROR_INVALIDDATA; - ff_read_chan_chunk(s, size, st->codec); + ff_mov_read_chan(s, size, st->codec); break; default: /* Jump */ if (size & 1) /* Always even aligned */ diff --git a/libavformat/avformat.h b/libavformat/avformat.h index c4d79368fb..e558096cf2 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -303,10 +303,9 @@ typedef struct AVOutputFormat { * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS */ int flags; - /** - * Currently only used to set pixel format if not YUV420P. - */ - int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *); + + void *dummy; + int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush); @@ -442,6 +441,8 @@ typedef struct AVInputFormat { const AVMetadataConv *metadata_conv; #endif + const AVClass *priv_class; ///< AVClass for the private context + /* private fields */ struct AVInputFormat *next; } AVInputFormat; @@ -790,6 +791,7 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled #define AVFMT_FLAG_RTP_HINT 0x0040 ///< Add RTP hinting to the output file #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down) +#define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted) int loop_input; @@ -1127,6 +1129,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, */ attribute_deprecated AVFormatContext *av_alloc_format_context(void); #endif +int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap); /** * Allocate an AVFormatContext. @@ -1136,6 +1139,13 @@ attribute_deprecated AVFormatContext *av_alloc_format_context(void); AVFormatContext *avformat_alloc_context(void); /** + * Allocate an AVFormatContext. + * avformat_free_context() can be used to free the context and everything + * allocated by the framework within it. + */ +AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputFormat *oformat, const char *filename); + +/** * Read packets of a media file to get stream information. This * is useful for file formats with no headers such as MPEG. This * function also computes the real framerate in case of MPEG-2 repeat @@ -1383,7 +1393,7 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, /** * media file output */ -int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap); +attribute_deprecated int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap); /** * Split a URL string into components. diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 82916a1156..c388298fef 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -25,6 +25,7 @@ #include <strings.h> #include "libavutil/intreadwrite.h" #include "libavutil/bswap.h" +#include "libavutil/opt.h" #include "avformat.h" #include "avi.h" #include "dv.h" @@ -59,6 +60,7 @@ typedef struct AVIStream { } AVIStream; typedef struct { + const AVClass *class; int64_t riff_end; int64_t movi_end; int64_t fsize; @@ -70,9 +72,24 @@ typedef struct { int stream_index; DVDemuxContext* dv_demux; int odml_depth; + int use_odml; #define MAX_ODML_DEPTH 1000 } AVIContext; + +static const AVOption options[] = { + { "use_odml", "use odml index", offsetof(AVIContext, use_odml), FF_OPT_TYPE_INT, 1, -1, 1, AV_OPT_FLAG_DECODING_PARAM}, + { NULL }, +}; + +static const AVClass demuxer_class = { + "AVI demuxer", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + + static const char avi_headers[][8] = { { 'R', 'I', 'F', 'F', 'A', 'V', 'I', ' ' }, { 'R', 'I', 'F', 'F', 'A', 'V', 'I', 'X' }, @@ -354,6 +371,8 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) if (get_riff(s, pb) < 0) return -1; + av_log(avi, AV_LOG_DEBUG, "use odml:%d\n", avi->use_odml); + avi->fsize = avio_size(pb); if(avi->fsize<=0) avi->fsize= avi->riff_end == 8 ? INT64_MAX : avi->riff_end; @@ -670,7 +689,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) break; case MKTAG('i', 'n', 'd', 'x'): i= avio_tell(pb); - if(pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX)){ + if(pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX) && avi->use_odml){ read_braindead_odml_indx(s, 0); } avio_seek(pb, i+size, SEEK_SET); @@ -994,7 +1013,7 @@ resync: ast->packet_size= 0; } - if(!avi->non_interleaved && ast->seek_pos > pkt->pos){ + if(!avi->non_interleaved && pkt->pos >= 0 && ast->seek_pos > pkt->pos){ av_free_packet(pkt); goto resync; } @@ -1383,4 +1402,5 @@ AVInputFormat ff_avi_demuxer = { avi_read_packet, avi_read_close, avi_read_seek, + .priv_class = &demuxer_class, }; diff --git a/libavformat/avio.h b/libavformat/avio.h index 9d805822d4..23e099d3fb 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -152,9 +152,9 @@ attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout); * constants, optionally ORed with other flags. * @{ */ -#define URL_RDONLY 0 /**< read-only */ -#define URL_WRONLY 1 /**< write-only */ -#define URL_RDWR 2 /**< read-write */ +#define URL_RDONLY 1 /**< read-only */ +#define URL_WRONLY 2 /**< write-only */ +#define URL_RDWR (URL_RDONLY|URL_WRONLY) /**< read-write */ /** * @} */ diff --git a/libavformat/caf.c b/libavformat/caf.c index 10daeda9fe..fd916746d8 100644 --- a/libavformat/caf.c +++ b/libavformat/caf.c @@ -57,60 +57,3 @@ const AVCodecTag ff_codec_caf_tags[] = { { CODEC_ID_NONE, 0 }, }; -typedef struct CafChannelLayout { - int64_t channel_layout; - uint32_t layout_tag; -} CafChannelLayout; - -static const CafChannelLayout caf_channel_layout[] = { - { AV_CH_LAYOUT_MONO, (100<<16) | 1}, //< kCAFChannelLayoutTag_Mono - { AV_CH_LAYOUT_STEREO, (101<<16) | 2}, //< kCAFChannelLayoutTag_Stereo - { AV_CH_LAYOUT_STEREO, (102<<16) | 2}, //< kCAFChannelLayoutTag_StereoHeadphones - { AV_CH_LAYOUT_2_1, (131<<16) | 3}, //< kCAFChannelLayoutTag_ITU_2_1 - { AV_CH_LAYOUT_2_2, (132<<16) | 4}, //< kCAFChannelLayoutTag_ITU_2_2 - { AV_CH_LAYOUT_QUAD, (108<<16) | 4}, //< kCAFChannelLayoutTag_Quadraphonic - { AV_CH_LAYOUT_SURROUND, (113<<16) | 3}, //< kCAFChannelLayoutTag_MPEG_3_0_A - { AV_CH_LAYOUT_4POINT0, (115<<16) | 4}, //< kCAFChannelLayoutTag_MPEG_4_0_A - { AV_CH_LAYOUT_5POINT0_BACK, (117<<16) | 5}, //< kCAFChannelLayoutTag_MPEG_5_0_A - { AV_CH_LAYOUT_5POINT0, (117<<16) | 5}, //< kCAFChannelLayoutTag_MPEG_5_0_A - { AV_CH_LAYOUT_5POINT1_BACK, (121<<16) | 6}, //< kCAFChannelLayoutTag_MPEG_5_1_A - { AV_CH_LAYOUT_5POINT1, (121<<16) | 6}, //< kCAFChannelLayoutTag_MPEG_5_1_A - { AV_CH_LAYOUT_7POINT1, (128<<16) | 8}, //< kCAFChannelLayoutTag_MPEG_7_1_C - { AV_CH_LAYOUT_7POINT1_WIDE, (126<<16) | 8}, //< kCAFChannelLayoutTag_MPEG_7_1_A - { AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY, (133<<16) | 3}, //< kCAFChannelLayoutTag_DVD_4 - { AV_CH_LAYOUT_2_1|AV_CH_LOW_FREQUENCY, (134<<16) | 4}, //< kCAFChannelLayoutTag_DVD_5 - { AV_CH_LAYOUT_2_2|AV_CH_LOW_FREQUENCY, (135<<16) | 4}, //< kCAFChannelLayoutTag_DVD_6 - { AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY, (136<<16) | 4}, //< kCAFChannelLayoutTag_DVD_10 - { AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY, (137<<16) | 5}, //< kCAFChannelLayoutTag_DVD_11 - { 0, 0}, -}; - -void ff_read_chan_chunk(AVFormatContext *s, int64_t size, AVCodecContext *codec) -{ - uint32_t layout_tag; - AVIOContext *pb = s->pb; - const CafChannelLayout *caf_layout = caf_channel_layout; - if (size != 12) { - // Channel descriptions not implemented - av_log_ask_for_sample(s, "Unimplemented channel layout.\n"); - avio_skip(pb, size); - return; - } - layout_tag = avio_rb32(pb); - if (layout_tag == 0x10000) { //< kCAFChannelLayoutTag_UseChannelBitmap - codec->channel_layout = avio_rb32(pb); - avio_skip(pb, 4); - return; - } - while (caf_layout->channel_layout) { - if (layout_tag == caf_layout->layout_tag) { - codec->channel_layout = caf_layout->channel_layout; - break; - } - caf_layout++; - } - if (!codec->channel_layout) - av_log(s, AV_LOG_WARNING, "Unknown channel layout.\n"); - avio_skip(pb, 8); -} - diff --git a/libavformat/caf.h b/libavformat/caf.h index 181cfaf92a..9c25f2c683 100644 --- a/libavformat/caf.h +++ b/libavformat/caf.h @@ -27,11 +27,8 @@ #ifndef AVFORMAT_CAF_H #define AVFORMAT_CAF_H -#include "avformat.h" #include "internal.h" extern const AVCodecTag ff_codec_caf_tags[]; -void ff_read_chan_chunk(AVFormatContext *s, int64_t size, AVCodecContext *codec); - #endif /* AVFORMAT_CAF_H */ diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 3cf4b6ca0c..ea9a3c17ae 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -260,7 +260,7 @@ static int read_header(AVFormatContext *s, case MKBETAG('c','h','a','n'): if (size < 12) return AVERROR_INVALIDDATA; - ff_read_chan_chunk(s, size, st->codec); + ff_mov_read_chan(s, size, st->codec); break; default: diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index a42bb69679..604e75183c 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -416,9 +416,6 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt) if (ffm->header[1] & FLAG_DTS) if (ffm_read_data(s, ffm->header+16, 4, 1) != 4) return -1; -#if 0 - av_hexdump_log(s, AV_LOG_DEBUG, ffm->header, FRAME_HEADER_SIZE); -#endif ffm->read_state = READ_DATA; /* fall thru */ case READ_DATA: diff --git a/libavformat/isom.c b/libavformat/isom.c index 3246df889f..76a7082148 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -420,3 +420,63 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext } return 0; } + +typedef struct MovChannelLayout { + int64_t channel_layout; + uint32_t layout_tag; +} MovChannelLayout; + +static const MovChannelLayout mov_channel_layout[] = { + { AV_CH_LAYOUT_MONO, (100<<16) | 1}, //< kCAFChannelLayoutTag_Mono + { AV_CH_LAYOUT_STEREO, (101<<16) | 2}, //< kCAFChannelLayoutTag_Stereo + { AV_CH_LAYOUT_STEREO, (102<<16) | 2}, //< kCAFChannelLayoutTag_StereoHeadphones + { AV_CH_LAYOUT_2_1, (131<<16) | 3}, //< kCAFChannelLayoutTag_ITU_2_1 + { AV_CH_LAYOUT_QUAD, (132<<16) | 4}, //< kCAFChannelLayoutTag_ITU_2_2 + { AV_CH_LAYOUT_2_2, (132<<16) | 4}, //< kCAFChannelLayoutTag_ITU_2_2 + { AV_CH_LAYOUT_QUAD, (108<<16) | 4}, //< kCAFChannelLayoutTag_Quadraphonic + { AV_CH_LAYOUT_SURROUND, (113<<16) | 3}, //< kCAFChannelLayoutTag_MPEG_3_0_A + { AV_CH_LAYOUT_4POINT0, (115<<16) | 4}, //< kCAFChannelLayoutTag_MPEG_4_0_A + { AV_CH_LAYOUT_5POINT0_BACK, (117<<16) | 5}, //< kCAFChannelLayoutTag_MPEG_5_0_A + { AV_CH_LAYOUT_5POINT0, (117<<16) | 5}, //< kCAFChannelLayoutTag_MPEG_5_0_A + { AV_CH_LAYOUT_5POINT1_BACK, (121<<16) | 6}, //< kCAFChannelLayoutTag_MPEG_5_1_A + { AV_CH_LAYOUT_5POINT1, (121<<16) | 6}, //< kCAFChannelLayoutTag_MPEG_5_1_A + { AV_CH_LAYOUT_7POINT1, (128<<16) | 8}, //< kCAFChannelLayoutTag_MPEG_7_1_C + { AV_CH_LAYOUT_7POINT1_WIDE, (126<<16) | 8}, //< kCAFChannelLayoutTag_MPEG_7_1_A + { AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY, (133<<16) | 3}, //< kCAFChannelLayoutTag_DVD_4 + { AV_CH_LAYOUT_2_1|AV_CH_LOW_FREQUENCY, (134<<16) | 4}, //< kCAFChannelLayoutTag_DVD_5 + { AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY, (135<<16) | 4}, //< kCAFChannelLayoutTag_DVD_6 + { AV_CH_LAYOUT_2_2|AV_CH_LOW_FREQUENCY, (135<<16) | 4}, //< kCAFChannelLayoutTag_DVD_6 + { AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY, (136<<16) | 4}, //< kCAFChannelLayoutTag_DVD_10 + { AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY, (137<<16) | 5}, //< kCAFChannelLayoutTag_DVD_11 + { 0, 0}, +}; + +void ff_mov_read_chan(AVFormatContext *s, int64_t size, AVCodecContext *codec) +{ + uint32_t layout_tag; + AVIOContext *pb = s->pb; + const MovChannelLayout *layouts = mov_channel_layout; + if (size != 12) { + // Channel descriptions not implemented + av_log_ask_for_sample(s, "Unimplemented container channel layout.\n"); + avio_skip(pb, size); + return; + } + layout_tag = avio_rb32(pb); + if (layout_tag == 0x10000) { //< kCAFChannelLayoutTag_UseChannelBitmap + codec->channel_layout = avio_rb32(pb); + avio_skip(pb, 4); + return; + } + while (layouts->channel_layout) { + if (layout_tag == layouts->layout_tag) { + codec->channel_layout = layouts->channel_layout; + break; + } + layouts++; + } + if (!codec->channel_layout) + av_log(s, AV_LOG_WARNING, "Unknown container channel layout.\n"); + avio_skip(pb, 8); +} + diff --git a/libavformat/isom.h b/libavformat/isom.h index 1df666f1ff..6848a7d4cc 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -154,5 +154,6 @@ int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom); enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags); int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries); +void ff_mov_read_chan(AVFormatContext *s, int64_t size, AVCodecContext *codec); #endif /* AVFORMAT_ISOM_H */ diff --git a/libavformat/mov.c b/libavformat/mov.c index 508def6881..41e23a0ad4 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -144,9 +144,12 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) case MKTAG(0xa9,'n','a','m'): key = "title"; break; case MKTAG(0xa9,'a','u','t'): case MKTAG(0xa9,'A','R','T'): key = "artist"; break; + case MKTAG( 'a','A','R','T'): key = "album_artist";break; case MKTAG(0xa9,'w','r','t'): key = "composer"; break; case MKTAG( 'c','p','r','t'): case MKTAG(0xa9,'c','p','y'): key = "copyright"; break; + case MKTAG(0xa9,'g','r','p'): key = "grouping"; break; + case MKTAG(0xa9,'l','y','r'): key = "lyrics"; break; case MKTAG(0xa9,'c','m','t'): case MKTAG(0xa9,'i','n','f'): key = "comment"; break; case MKTAG(0xa9,'a','l','b'): key = "album"; break; @@ -2181,6 +2184,15 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + if (atom.size < 16) + return AVERROR_INVALIDDATA; + avio_skip(pb, 4); + ff_mov_read_chan(c->fc, atom.size - 4, c->fc->streams[0]->codec); + return 0; +} + static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('a','v','s','s'), mov_read_extradata }, { MKTAG('c','h','p','l'), mov_read_chpl }, @@ -2234,6 +2246,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('d','a','c','3'), mov_read_dac3 }, /* AC-3 info */ { MKTAG('w','i','d','e'), mov_read_wide }, /* place holder */ { MKTAG('c','m','o','v'), mov_read_cmov }, +{ MKTAG('c','h','a','n'), mov_read_chan }, { 0, NULL } }; diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 8996b725fd..eb53486aeb 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -663,9 +663,6 @@ static int mpegts_push_data(MpegTSFilter *filter, if (pes->data_index == PES_START_SIZE) { /* we got all the PES or section header. We can now decide */ -#if 0 - av_hex_dump_log(pes->stream, AV_LOG_DEBUG, pes->header, pes->data_index); -#endif if (pes->header[0] == 0x00 && pes->header[1] == 0x00 && pes->header[2] == 0x01) { /* it must be an mpeg2 PES stream */ diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index ccaa2f80aa..3ca743a2ba 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -421,7 +421,7 @@ static MpegTSService *mpegts_add_service(MpegTSWrite *ts, service = av_mallocz(sizeof(MpegTSService)); if (!service) return NULL; - service->pmt.pid = ts->pmt_start_pid + ts->nb_services - 1; + service->pmt.pid = ts->pmt_start_pid + ts->nb_services; service->sid = sid; service->provider_name = av_strdup(provider_name); service->name = av_strdup(name); diff --git a/libavformat/network.h b/libavformat/network.h index 74e6f0bbcc..f2a0c97d77 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -78,7 +78,7 @@ static inline int ff_network_wait_fd(int fd, int write) struct pollfd p = { .fd = fd, .events = ev, .revents = 0 }; int ret; ret = poll(&p, 1, 100); - return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : AVERROR(EAGAIN); + return ret < 0 ? ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN); } static inline void ff_network_close(void) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 272072283b..47eaa2c81c 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -175,6 +175,7 @@ static void build_frame_code(AVFormatContext *s){ } key_frame= intra_only; +#if 1 if(is_audio){ int frame_bytes= codec->frame_size*(int64_t)codec->bit_rate / (8*codec->sample_rate); int pts; @@ -198,6 +199,7 @@ static void build_frame_code(AVFormatContext *s){ ft->pts_delta=1; start2++; } +#endif if(codec->has_b_frames){ pred_count=5; diff --git a/libavformat/output-example.c b/libavformat/output-example.c index 27db78c658..1a429638d1 100644 --- a/libavformat/output-example.c +++ b/libavformat/output-example.c @@ -442,26 +442,16 @@ int main(int argc, char **argv) filename = argv[1]; - /* auto detect the output format from the name. default is - mpeg. */ - fmt = av_guess_format(NULL, filename, NULL); - if (!fmt) { + /* allocate the output media context */ + oc = avformat_alloc_output_context(NULL, NULL, filename); + if (!oc) { printf("Could not deduce output format from file extension: using MPEG.\n"); - fmt = av_guess_format("mpeg", NULL, NULL); + oc = avformat_alloc_output_context("mpeg", NULL, filename); } - if (!fmt) { - fprintf(stderr, "Could not find suitable output format\n"); - exit(1); - } - - /* allocate the output media context */ - oc = avformat_alloc_context(); if (!oc) { - fprintf(stderr, "Memory error\n"); exit(1); } - oc->oformat = fmt; - snprintf(oc->filename, sizeof(oc->filename), "%s", filename); + fmt= oc->oformat; /* add the audio and video streams using the default format codecs and initialize the codecs */ @@ -474,13 +464,6 @@ int main(int argc, char **argv) audio_st = add_audio_stream(oc, fmt->audio_codec); } - /* set the output parameters (must be done even if no - parameters). */ - if (av_set_parameters(oc, NULL) < 0) { - fprintf(stderr, "Invalid output format parameters\n"); - exit(1); - } - av_dump_format(oc, 0, filename, 1); /* now that all the parameters are set, we can open the audio and diff --git a/libavformat/utils.c b/libavformat/utils.c index ffb114d5e9..f99adab712 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -496,6 +496,10 @@ int av_open_input_stream(AVFormatContext **ic_ptr, err = AVERROR(ENOMEM); goto fail; } + if (fmt->priv_class) { + *(const AVClass**)ic->priv_data= fmt->priv_class; + av_opt_set_defaults(ic->priv_data); + } } else { ic->priv_data = NULL; } @@ -504,13 +508,13 @@ int av_open_input_stream(AVFormatContext **ic_ptr, if (ic->pb) ff_id3v2_read(ic, ID3v2_DEFAULT_MAGIC); - if (ic->iformat->read_header) { + if (!(ic->flags&AVFMT_FLAG_PRIV_OPT) && ic->iformat->read_header) { err = ic->iformat->read_header(ic, ap); if (err < 0) goto fail; } - if (pb && !ic->data_offset) + if (!(ic->flags&AVFMT_FLAG_PRIV_OPT) && pb && !ic->data_offset) ic->data_offset = avio_tell(ic->pb); #if FF_API_OLD_METADATA @@ -541,6 +545,22 @@ int av_open_input_stream(AVFormatContext **ic_ptr, return err; } +int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap){ + int err; + + if (ic->iformat->read_header) { + err = ic->iformat->read_header(ic, ap); + if (err < 0) + return err; + } + + if (ic->pb && !ic->data_offset) + ic->data_offset = avio_tell(ic->pb); + + return 0; +} + + /** size of probe buffer, for guessing file type from file contents */ #define PROBE_BUF_MIN 2048 #define PROBE_BUF_MAX (1<<20) @@ -2807,14 +2827,53 @@ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap) } else s->priv_data = NULL; - if (s->oformat->set_parameters) { - ret = s->oformat->set_parameters(s, ap); - if (ret < 0) - return ret; - } return 0; } +AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputFormat *oformat, const char *filename){ + AVFormatContext *s= avformat_alloc_context(); + if(!s) + goto nomem; + + if(!oformat){ + if (format) { + oformat = av_guess_format(format, NULL, NULL); + if (!oformat) { + av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format); + goto error; + } + } else { + oformat = av_guess_format(NULL, filename, NULL); + if (!oformat) { + av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n", + filename); + goto error; + } + } + } + + s->oformat= oformat; + if (s->oformat->priv_data_size > 0) { + s->priv_data = av_mallocz(s->oformat->priv_data_size); + if (!s->priv_data) + goto nomem; + if (s->oformat->priv_class) { + *(const AVClass**)s->priv_data= s->oformat->priv_class; + av_opt_set_defaults(s->priv_data); + } + } else + s->priv_data = NULL; + + if(filename) + av_strlcpy(s->filename, filename, sizeof(s->filename)); + return s; +nomem: + av_log(s, AV_LOG_ERROR, "Out of memory\n"); +error: + avformat_free_context(s); + return NULL; +} + static int validate_codec_tag(AVFormatContext *s, AVStream *st) { const AVCodecTag *avctag; |