From 89f6e8a20c07ad779ca374fdc5b16a22a37a6150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 30 Jan 2012 22:47:40 +0200 Subject: flvdec: Interpret a toplevel 'object' type metadata item as normal metadata, too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, we've only passed the key string on to the recursive amf_parse_object for the mixedarray type, not for 'object'. By passing the key string on, the recursive amf_parse_object can store the amf objects as metadata. This kind of data was seen in data from XSplit Broadcaster, received over RTMP via Wowza. This patch allows reading this metadata. Signed-off-by: Martin Storsjö --- libavformat/flvdec.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'libavformat') diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 9296ef9d31..ad38653d76 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -240,22 +240,18 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0) return -1; break; - case AMF_DATA_TYPE_OBJECT: { - unsigned int keylen; - + case AMF_DATA_TYPE_OBJECT: if ((vstream || astream) && key && !strcmp(KEYFRAMES_TAG, key) && depth == 1) if (parse_keyframes_index(s, ioc, vstream ? vstream : astream, max_pos) < 0) return -1; - while(avio_tell(ioc) < max_pos - 2 && (keylen = avio_rb16(ioc))) { - avio_skip(ioc, keylen); //skip key string - if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0) + while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { + if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; //if we couldn't skip, bomb out. } if(avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; - } break; case AMF_DATA_TYPE_NULL: case AMF_DATA_TYPE_UNDEFINED: -- cgit v1.2.3 From 75ab1e62d4187c8ad627835ee8fcf38501477caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 18 Jan 2012 15:12:10 +0200 Subject: movdec: Ignore sample_degradation_priority bits when checking first_sample_flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the first packet of a track fragment run to get the keyframe flag set properly if sample_degradation_priority is nonzero. This makes the keyframes flag be set properly for ismv files created by Microsoft. Signed-off-by: Martin Storsjö --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavformat') diff --git a/libavformat/mov.c b/libavformat/mov.c index b7d8a55933..0ce32e0f8e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2250,7 +2250,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->ctts_data[sc->ctts_count].duration = (flags & 0x800) ? avio_rb32(pb) : 0; sc->ctts_count++; if ((keyframe = st->codec->codec_type == AVMEDIA_TYPE_AUDIO || - (flags & 0x004 && !i && !sample_flags) || sample_flags & 0x2000000)) + (flags & 0x004 && !i && !(sample_flags & 0xffff0000)) || sample_flags & 0x2000000)) distance = 0; av_add_index_entry(st, offset, dts, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); -- cgit v1.2.3 From 183eaa9a2525de485fe2e0e9e39671665ffc6df2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 27 Jan 2012 12:29:37 +0100 Subject: lavf: reorder AVInput/OutputFormat fields. Put all private fields at the end and mark them as such so they can be easily changed/removed. This breaks ABI. --- libavformat/avformat.h | 110 +++++++++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 49 deletions(-) (limited to 'libavformat') diff --git a/libavformat/avformat.h b/libavformat/avformat.h index a78c1e3b72..09b78a9f64 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -309,13 +309,39 @@ typedef struct AVOutputFormat { const char *long_name; const char *mime_type; const char *extensions; /**< comma-separated filename extensions */ + /* output support */ + enum CodecID audio_codec; /**< default audio codec */ + enum CodecID video_codec; /**< default video codec */ + enum CodecID subtitle_codec; /**< default subtitle codec */ + /** + * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, + * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, + * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH + */ + int flags; + + /** + * List of supported codec_id-codec_tag pairs, ordered by "better + * choice first". The arrays are all terminated by CODEC_ID_NONE. + */ + const struct AVCodecTag * const *codec_tag; + + + const AVClass *priv_class; ///< AVClass for the private context + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + struct AVOutputFormat *next; /** * size of private data so that it can be allocated in the wrapper */ int priv_data_size; - /* output support */ - enum CodecID audio_codec; /**< default audio codec */ - enum CodecID video_codec; /**< default video codec */ + int (*write_header)(struct AVFormatContext *); /** * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags, @@ -326,28 +352,11 @@ typedef struct AVOutputFormat { */ int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); int (*write_trailer)(struct AVFormatContext *); - /** - * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, - * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, - * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH - */ - int flags; /** * Currently only used to set pixel format if not YUV420P. */ int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush); - - /** - * List of supported codec_id-codec_tag pairs, ordered by "better - * choice first". The arrays are all terminated by CODEC_ID_NONE. - */ - const struct AVCodecTag * const *codec_tag; - - enum CodecID subtitle_codec; /**< default subtitle codec */ - - const AVClass *priv_class; ///< AVClass for the private context - /** * Test if the given codec can be stored in this container. * @@ -355,9 +364,6 @@ typedef struct AVOutputFormat { * A negative number if unknown. */ int (*query_codec)(enum CodecID id, int std_compliance); - - /* private fields */ - struct AVOutputFormat *next; } AVOutputFormat; /** * @} @@ -381,6 +387,38 @@ typedef struct AVInputFormat { */ const char *long_name; + /** + * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, + * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, + * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK. + */ + int flags; + + /** + * If extensions are defined, then no probe is done. You should + * usually not use extension format guessing because it is not + * reliable enough + */ + const char *extensions; + + const struct AVCodecTag * const *codec_tag; + + const AVClass *priv_class; ///< AVClass for the private context + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + struct AVInputFormat *next; + + /** + * General purpose read-only value that the format can use. + */ + int value; + /** * Size of private data so that it can be allocated in the wrapper. */ @@ -436,25 +474,6 @@ typedef struct AVInputFormat { int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit); - /** - * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, - * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, - * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK. - */ - int flags; - - /** - * If extensions are defined, then no probe is done. You should - * usually not use extension format guessing because it is not - * reliable enough - */ - const char *extensions; - - /** - * General purpose read-only value that the format can use. - */ - int value; - /** * Start/resume playing - only meaningful if using a network-based format * (RTSP). @@ -467,8 +486,6 @@ typedef struct AVInputFormat { */ int (*read_pause)(struct AVFormatContext *); - const struct AVCodecTag * const *codec_tag; - /** * Seek to timestamp ts. * Seeking will be done so that the point from which all active streams @@ -476,11 +493,6 @@ typedef struct AVInputFormat { * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. */ int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); - - const AVClass *priv_class; ///< AVClass for the private context - - /* private fields */ - struct AVInputFormat *next; } AVInputFormat; /** * @} -- cgit v1.2.3 From afa4069e3ba373ed958f5fd392c184b084287b46 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 29 Jan 2012 12:22:49 +0100 Subject: lavc/lavf: remove unnecessary symbols from the symbol version script. --- libavformat/libavformat.v | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'libavformat') diff --git a/libavformat/libavformat.v b/libavformat/libavformat.v index c5dc982878..6f11d600b9 100644 --- a/libavformat/libavformat.v +++ b/libavformat/libavformat.v @@ -1,29 +1,4 @@ LIBAVFORMAT_$MAJOR { global: av*; - #FIXME those are for avserver - ff_inet_aton; - ff_socket_nonblock; - ffm_set_write_index; - ffm_read_write_index; - ffm_write_write_index; - ff_rtsp_parse_line; - ff_rtp_get_local_rtp_port; - ff_rtp_get_local_rtcp_port; - ffio_open_dyn_packet_buf; - url_open; - url_close; - url_write; - url_get_max_packet_size; - #those are deprecated, remove on next bump - find_info_tag; - parse_date; - dump_format; - url_*; - get_*; - put_*; - udp_set_remote_url; - udp_get_local_port; - init_checksum; - init_put_byte; local: *; }; -- cgit v1.2.3 From 9a463917d30147a9728a7b19b03c217527e09046 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 31 Jan 2012 07:46:18 +0100 Subject: lavf: remove the pointless value field from flv and iv8 The demuxers don't use it in any way. --- libavformat/flvdec.c | 1 - libavformat/iv8.c | 1 - 2 files changed, 2 deletions(-) (limited to 'libavformat') diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index ad38653d76..1e1c29b391 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -672,5 +672,4 @@ AVInputFormat ff_flv_demuxer = { #endif .read_close = flv_read_close, .extensions = "flv", - .value = CODEC_ID_FLV1, }; diff --git a/libavformat/iv8.c b/libavformat/iv8.c index 903de6f8a4..e597911a97 100644 --- a/libavformat/iv8.c +++ b/libavformat/iv8.c @@ -115,5 +115,4 @@ AVInputFormat ff_iv8_demuxer = { .read_header = read_header, .read_packet = read_packet, .flags= AVFMT_GENERIC_INDEX, - .value = CODEC_ID_MPEG4, }; -- cgit v1.2.3 From f7fe41a04f962707a99597d2ea49d73ca90b23a0 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 31 Jan 2012 07:50:31 +0100 Subject: lavf: rename AVInputFormat.value to raw_codec_id. It's only used by raw demuxers for storing the codec id. --- libavformat/aacdec.c | 4 ++-- libavformat/ac3dec.c | 4 ++-- libavformat/adxdec.c | 4 ++-- libavformat/avformat.h | 4 ++-- libavformat/dtsdec.c | 2 +- libavformat/flacdec.c | 2 +- libavformat/gsmdec.c | 4 ++-- libavformat/ingenientdec.c | 2 +- libavformat/pcmdec.c | 2 +- libavformat/rawdec.c | 16 ++++++++-------- libavformat/rawdec.h | 2 +- libavformat/rawvideodec.c | 2 +- 12 files changed, 24 insertions(+), 24 deletions(-) (limited to 'libavformat') diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index df94d15831..992376ed38 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -70,7 +70,7 @@ static int adts_aac_read_header(AVFormatContext *s) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = s->iformat->value; + st->codec->codec_id = s->iformat->raw_codec_id; st->need_parsing = AVSTREAM_PARSE_FULL; ff_id3v1_read(s); @@ -89,5 +89,5 @@ AVInputFormat ff_aac_demuxer = { .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "aac", - .value = CODEC_ID_AAC, + .raw_codec_id = CODEC_ID_AAC, }; diff --git a/libavformat/ac3dec.c b/libavformat/ac3dec.c index ca6aee3685..4078b1b6bc 100644 --- a/libavformat/ac3dec.c +++ b/libavformat/ac3dec.c @@ -78,7 +78,7 @@ AVInputFormat ff_ac3_demuxer = { .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "ac3", - .value = CODEC_ID_AC3, + .raw_codec_id = CODEC_ID_AC3, }; #endif @@ -96,6 +96,6 @@ AVInputFormat ff_eac3_demuxer = { .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "eac3", - .value = CODEC_ID_EAC3, + .raw_codec_id = CODEC_ID_EAC3, }; #endif diff --git a/libavformat/adxdec.c b/libavformat/adxdec.c index 243160940c..305c67431b 100644 --- a/libavformat/adxdec.c +++ b/libavformat/adxdec.c @@ -94,7 +94,7 @@ static int adx_read_header(AVFormatContext *s) return ret; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = s->iformat->value; + st->codec->codec_id = s->iformat->raw_codec_id; avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, avctx->sample_rate); @@ -108,6 +108,6 @@ AVInputFormat ff_adx_demuxer = { .read_header = adx_read_header, .read_packet = adx_read_packet, .extensions = "adx", - .value = CODEC_ID_ADPCM_ADX, + .raw_codec_id = CODEC_ID_ADPCM_ADX, .flags = AVFMT_GENERIC_INDEX, }; diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 09b78a9f64..217d8139df 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -415,9 +415,9 @@ typedef struct AVInputFormat { struct AVInputFormat *next; /** - * General purpose read-only value that the format can use. + * Raw demuxers store their codec ID here. */ - int value; + int raw_codec_id; /** * Size of private data so that it can be allocated in the wrapper. diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c index d61855d360..95bae54519 100644 --- a/libavformat/dtsdec.c +++ b/libavformat/dtsdec.c @@ -73,5 +73,5 @@ AVInputFormat ff_dts_demuxer = { .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "dts", - .value = CODEC_ID_DTS, + .raw_codec_id = CODEC_ID_DTS, }; diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index d127dc209f..7174fcf758 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -157,5 +157,5 @@ AVInputFormat ff_flac_demuxer = { .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "flac", - .value = CODEC_ID_FLAC, + .raw_codec_id = CODEC_ID_FLAC, }; diff --git a/libavformat/gsmdec.c b/libavformat/gsmdec.c index 5d6495860a..3525a038c7 100644 --- a/libavformat/gsmdec.c +++ b/libavformat/gsmdec.c @@ -62,7 +62,7 @@ static int gsm_read_header(AVFormatContext *s) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = s->iformat->value; + st->codec->codec_id = s->iformat->raw_codec_id; st->codec->channels = 1; st->codec->sample_rate = c->sample_rate; st->codec->bit_rate = GSM_BLOCK_SIZE * 8 * c->sample_rate / GSM_BLOCK_SAMPLES; @@ -94,6 +94,6 @@ AVInputFormat ff_gsm_demuxer = { .read_packet = gsm_read_packet, .flags = AVFMT_GENERIC_INDEX, .extensions = "gsm", - .value = CODEC_ID_GSM, + .raw_codec_id = CODEC_ID_GSM, .priv_class = &class, }; diff --git a/libavformat/ingenientdec.c b/libavformat/ingenientdec.c index 35ac649695..bed525fad6 100644 --- a/libavformat/ingenientdec.c +++ b/libavformat/ingenientdec.c @@ -68,6 +68,6 @@ AVInputFormat ff_ingenient_demuxer = { .read_packet = ingenient_read_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "cgi", // FIXME - .value = CODEC_ID_MJPEG, + .raw_codec_id = CODEC_ID_MJPEG, .priv_class = &ingenient_demuxer_class, }; diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c index b61fb33764..1e36cc4e76 100644 --- a/libavformat/pcmdec.c +++ b/libavformat/pcmdec.c @@ -70,7 +70,7 @@ AVInputFormat ff_pcm_ ## name_ ## _demuxer = { \ .read_seek = pcm_read_seek, \ .flags = AVFMT_GENERIC_INDEX, \ .extensions = ext, \ - .value = codec, \ + .raw_codec_id = codec, \ .priv_class = &name_ ## _demuxer_class, \ }; diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 9400a0bd32..73b3709ac1 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -38,7 +38,7 @@ int ff_raw_read_header(AVFormatContext *s) if (!st) return AVERROR(ENOMEM); - id = s->iformat->value; + id = s->iformat->raw_codec_id; if (id == CODEC_ID_RAWVIDEO) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; } else { @@ -126,7 +126,7 @@ int ff_raw_audio_read_header(AVFormatContext *s) if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = s->iformat->value; + st->codec->codec_id = s->iformat->raw_codec_id; st->need_parsing = AVSTREAM_PARSE_FULL; st->start_time = 0; /* the parameters will be extracted from the compressed bitstream */ @@ -150,7 +150,7 @@ int ff_raw_video_read_header(AVFormatContext *s) } st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = s->iformat->value; + st->codec->codec_id = s->iformat->raw_codec_id; st->need_parsing = AVSTREAM_PARSE_FULL; if ((ret = av_parse_video_rate(&framerate, s1->framerate)) < 0) { @@ -182,7 +182,7 @@ AVInputFormat ff_g722_demuxer = { .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "g722,722", - .value = CODEC_ID_ADPCM_G722, + .raw_codec_id = CODEC_ID_ADPCM_G722, }; #endif @@ -194,7 +194,7 @@ AVInputFormat ff_latm_demuxer = { .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "latm", - .value = CODEC_ID_AAC_LATM, + .raw_codec_id = CODEC_ID_AAC_LATM, }; #endif @@ -210,7 +210,7 @@ AVInputFormat ff_mlp_demuxer = { .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "mlp", - .value = CODEC_ID_MLP, + .raw_codec_id = CODEC_ID_MLP, }; #endif @@ -222,7 +222,7 @@ AVInputFormat ff_truehd_demuxer = { .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "thd", - .value = CODEC_ID_TRUEHD, + .raw_codec_id = CODEC_ID_TRUEHD, }; #endif @@ -234,7 +234,7 @@ AVInputFormat ff_shorten_demuxer = { .read_packet = ff_raw_read_partial_packet, .flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK, .extensions = "shn", - .value = CODEC_ID_SHORTEN, + .raw_codec_id = CODEC_ID_SHORTEN, }; #endif diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h index cfb1689cd9..4cce2cf901 100644 --- a/libavformat/rawdec.h +++ b/libavformat/rawdec.h @@ -67,7 +67,7 @@ AVInputFormat ff_ ## shortname ## _demuxer = {\ .read_packet = ff_raw_read_partial_packet,\ .extensions = ext,\ .flags = AVFMT_GENERIC_INDEX,\ - .value = id,\ + .raw_codec_id = id,\ .priv_data_size = sizeof(FFRawVideoDemuxerContext),\ .priv_class = &shortname ## _demuxer_class,\ }; diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c index 6ca17d5253..5db4e91f2e 100644 --- a/libavformat/rawvideodec.c +++ b/libavformat/rawvideodec.c @@ -68,6 +68,6 @@ AVInputFormat ff_rawvideo_demuxer = { .read_packet = rawvideo_read_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "yuv,cif,qcif,rgb", - .value = CODEC_ID_RAWVIDEO, + .raw_codec_id = CODEC_ID_RAWVIDEO, .priv_class = &rawvideo_demuxer_class, }; -- cgit v1.2.3 From af08d9aeea870de017139f7b1c44b7d816cf8e56 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 8 Dec 2011 06:57:44 +0100 Subject: lavc: add avcodec_is_open(). It allows to check whether an AVCodecContext is open in a documented way. Right now the undocumented way this check is done in lavf/lavc is by checking whether AVCodecContext.codec is NULL. However it's desirable to be able to set AVCodecContext.codec before avcodec_open2(). --- libavformat/utils.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libavformat') diff --git a/libavformat/utils.c b/libavformat/utils.c index 9c59947fb7..1b2239a068 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2006,7 +2006,7 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option AVFrame picture; AVPacket pkt = *avpkt; - if(!st->codec->codec){ + if (!avcodec_is_open(st->codec)) { AVDictionary *thread_opt = NULL; codec = avcodec_find_decoder(st->codec->codec_id); @@ -2354,8 +2354,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) // close codecs which were opened in try_decode_frame() for(i=0;inb_streams;i++) { st = ic->streams[i]; - if(st->codec->codec) - avcodec_close(st->codec); + avcodec_close(st->codec); } for(i=0;inb_streams;i++) { st = ic->streams[i]; -- cgit v1.2.3 From bc901998487bf9b77a423961d9f961bcc28a9291 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 28 Jan 2012 19:15:15 +0100 Subject: lavc: set AVCodecContext.codec in avcodec_get_context_defaults3(). This way, if the AVCodecContext is allocated for a specific codec, the caller doesn't need to store this codec separately and then pass it again to avcodec_open2(). It also allows to set codec private options using av_opt_set_* before opening the codec. --- libavformat/utils.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libavformat') diff --git a/libavformat/utils.c b/libavformat/utils.c index 1b2239a068..cf7180b3cf 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2009,7 +2009,9 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option if (!avcodec_is_open(st->codec)) { AVDictionary *thread_opt = NULL; - codec = avcodec_find_decoder(st->codec->codec_id); + codec = st->codec->codec ? st->codec->codec : + avcodec_find_decoder(st->codec->codec_id); + if (!codec) return -1; @@ -2169,8 +2171,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; } } - assert(!st->codec->codec); - codec = avcodec_find_decoder(st->codec->codec_id); + codec = st->codec->codec ? st->codec->codec : + avcodec_find_decoder(st->codec->codec_id); /* force thread count to 1 since the h264 decoder will not extract SPS * and PPS to extradata during multi-threaded decoding */ -- cgit v1.2.3 From dd6d3b0e025cb2a16022665dbb8ab1be18dc05e8 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 27 Jan 2012 13:33:09 +0100 Subject: lavf: add functions for accessing the fourcc<->CodecID mapping tables. Fixes bug 212. --- libavformat/Makefile | 54 +++++++++++++++++++++++++------------------------- libavformat/avformat.h | 24 ++++++++++++++++++++++ libavformat/utils.c | 9 +++++++++ 3 files changed, 60 insertions(+), 27 deletions(-) (limited to 'libavformat') diff --git a/libavformat/Makefile b/libavformat/Makefile index 45f757690d..06718d2485 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -10,6 +10,7 @@ OBJS = allformats.o \ metadata.o \ options.o \ os_support.o \ + riff.o \ sdp.o \ seek.o \ utils.o \ @@ -25,8 +26,8 @@ OBJS-$(CONFIG_ADX_DEMUXER) += adxdec.o OBJS-$(CONFIG_ADX_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 -OBJS-$(CONFIG_AIFF_MUXER) += aiffenc.o riff.o +OBJS-$(CONFIG_AIFF_DEMUXER) += aiffdec.o pcm.o +OBJS-$(CONFIG_AIFF_MUXER) += aiffenc.o OBJS-$(CONFIG_AMR_DEMUXER) += amr.o OBJS-$(CONFIG_AMR_MUXER) += amr.o OBJS-$(CONFIG_ANM_DEMUXER) += anm.o @@ -34,14 +35,14 @@ OBJS-$(CONFIG_APC_DEMUXER) += apc.o OBJS-$(CONFIG_APE_DEMUXER) += ape.o apetag.o OBJS-$(CONFIG_APPLEHTTP_DEMUXER) += applehttp.o OBJS-$(CONFIG_ASF_DEMUXER) += asfdec.o asf.o asfcrypt.o \ - riff.o avlanguage.o -OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o riff.o + avlanguage.o +OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o OBJS-$(CONFIG_ASS_DEMUXER) += assdec.o OBJS-$(CONFIG_ASS_MUXER) += assenc.o OBJS-$(CONFIG_AU_DEMUXER) += au.o pcm.o OBJS-$(CONFIG_AU_MUXER) += au.o -OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o riff.o -OBJS-$(CONFIG_AVI_MUXER) += avienc.o riff.o +OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o +OBJS-$(CONFIG_AVI_MUXER) += avienc.o OBJS-$(CONFIG_AVISYNTH) += avisynth.o OBJS-$(CONFIG_AVM2_MUXER) += swfenc.o OBJS-$(CONFIG_AVS_DEMUXER) += avs.o vocdec.o voc.o @@ -51,7 +52,7 @@ OBJS-$(CONFIG_BINK_DEMUXER) += bink.o OBJS-$(CONFIG_BMV_DEMUXER) += bmv.o OBJS-$(CONFIG_C93_DEMUXER) += c93.o vocdec.o voc.o OBJS-$(CONFIG_CAF_DEMUXER) += cafdec.o caf.o mov.o mov_chan.o \ - riff.o isom.o + isom.o OBJS-$(CONFIG_CAVSVIDEO_DEMUXER) += cavsvideodec.o rawdec.o OBJS-$(CONFIG_CAVSVIDEO_MUXER) += rawenc.o OBJS-$(CONFIG_CDG_DEMUXER) += cdg.o @@ -68,7 +69,7 @@ OBJS-$(CONFIG_DTS_DEMUXER) += dtsdec.o rawdec.o OBJS-$(CONFIG_DTS_MUXER) += rawenc.o OBJS-$(CONFIG_DV_DEMUXER) += dv.o OBJS-$(CONFIG_DV_MUXER) += dvenc.o -OBJS-$(CONFIG_DXA_DEMUXER) += dxa.o riff.o +OBJS-$(CONFIG_DXA_DEMUXER) += dxa.o OBJS-$(CONFIG_EA_CDATA_DEMUXER) += eacdata.o OBJS-$(CONFIG_EA_DEMUXER) += electronicarts.o OBJS-$(CONFIG_EAC3_DEMUXER) += ac3dec.o rawdec.o @@ -112,7 +113,7 @@ OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o OBJS-$(CONFIG_IPMOVIE_DEMUXER) += ipmovie.o OBJS-$(CONFIG_ISS_DEMUXER) += iss.o OBJS-$(CONFIG_IV8_DEMUXER) += iv8.o -OBJS-$(CONFIG_IVF_DEMUXER) += ivfdec.o riff.o +OBJS-$(CONFIG_IVF_DEMUXER) += ivfdec.o OBJS-$(CONFIG_IVF_MUXER) += ivfenc.o OBJS-$(CONFIG_JV_DEMUXER) += jvdec.o OBJS-$(CONFIG_LATM_DEMUXER) += rawdec.o @@ -122,9 +123,9 @@ OBJS-$(CONFIG_LXF_DEMUXER) += lxfdec.o OBJS-$(CONFIG_M4V_DEMUXER) += m4vdec.o rawdec.o OBJS-$(CONFIG_M4V_MUXER) += rawenc.o OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \ - riff.o isom.o rmdec.o rm.o + isom.o rmdec.o rm.o OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o \ - riff.o isom.o avc.o \ + isom.o avc.o \ flacenc_header.o avlanguage.o OBJS-$(CONFIG_MD5_MUXER) += md5enc.o OBJS-$(CONFIG_MJPEG_DEMUXER) += rawdec.o @@ -133,9 +134,9 @@ OBJS-$(CONFIG_MLP_DEMUXER) += rawdec.o OBJS-$(CONFIG_MLP_MUXER) += rawenc.o OBJS-$(CONFIG_MM_DEMUXER) += mm.o OBJS-$(CONFIG_MMF_DEMUXER) += mmf.o pcm.o -OBJS-$(CONFIG_MMF_MUXER) += mmf.o riff.o -OBJS-$(CONFIG_MOV_DEMUXER) += mov.o riff.o isom.o mov_chan.o -OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o isom.o avc.o \ +OBJS-$(CONFIG_MMF_MUXER) += mmf.o +OBJS-$(CONFIG_MOV_DEMUXER) += mov.o isom.o mov_chan.o +OBJS-$(CONFIG_MOV_MUXER) += movenc.o isom.o avc.o \ movenchint.o rtpenc_chain.o \ mov_chan.o OBJS-$(CONFIG_MP2_MUXER) += mp3enc.o rawenc.o @@ -164,9 +165,9 @@ OBJS-$(CONFIG_MXG_DEMUXER) += mxg.o OBJS-$(CONFIG_NC_DEMUXER) += ncdec.o OBJS-$(CONFIG_NSV_DEMUXER) += nsvdec.o OBJS-$(CONFIG_NULL_MUXER) += nullenc.o -OBJS-$(CONFIG_NUT_DEMUXER) += nutdec.o nut.o riff.o -OBJS-$(CONFIG_NUT_MUXER) += nutenc.o nut.o riff.o -OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o riff.o +OBJS-$(CONFIG_NUT_DEMUXER) += nutdec.o nut.o +OBJS-$(CONFIG_NUT_MUXER) += nutenc.o nut.o +OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ oggparsecelt.o \ oggparsedirac.o \ @@ -176,7 +177,6 @@ OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ oggparsespeex.o \ oggparsetheora.o \ oggparsevorbis.o \ - riff.o \ vorbiscomment.o OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \ vorbiscomment.o @@ -301,28 +301,28 @@ OBJS-$(CONFIG_VMD_DEMUXER) += sierravmd.o OBJS-$(CONFIG_VOC_DEMUXER) += vocdec.o voc.o OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o OBJS-$(CONFIG_VQF_DEMUXER) += vqf.o -OBJS-$(CONFIG_W64_DEMUXER) += wav.o riff.o pcm.o -OBJS-$(CONFIG_WAV_DEMUXER) += wav.o riff.o pcm.o -OBJS-$(CONFIG_WAV_MUXER) += wav.o riff.o +OBJS-$(CONFIG_W64_DEMUXER) += wav.o pcm.o +OBJS-$(CONFIG_WAV_DEMUXER) += wav.o pcm.o +OBJS-$(CONFIG_WAV_MUXER) += wav.o OBJS-$(CONFIG_WC3_DEMUXER) += wc3movie.o OBJS-$(CONFIG_WEBM_MUXER) += matroskaenc.o matroska.o \ - riff.o isom.o avc.o \ + isom.o avc.o \ flacenc_header.o avlanguage.o OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood_aud.o OBJS-$(CONFIG_WSVQA_DEMUXER) += westwood_vqa.o OBJS-$(CONFIG_WTV_DEMUXER) += wtv.o asfdec.o asf.o asfcrypt.o \ - avlanguage.o mpegts.o isom.o riff.o + avlanguage.o mpegts.o isom.o OBJS-$(CONFIG_WV_DEMUXER) += wv.o apetag.o OBJS-$(CONFIG_XA_DEMUXER) += xa.o -OBJS-$(CONFIG_XMV_DEMUXER) += xmv.o riff.o -OBJS-$(CONFIG_XWMA_DEMUXER) += xwma.o riff.o +OBJS-$(CONFIG_XMV_DEMUXER) += xmv.o +OBJS-$(CONFIG_XWMA_DEMUXER) += xwma.o OBJS-$(CONFIG_YOP_DEMUXER) += yop.o OBJS-$(CONFIG_YUV4MPEGPIPE_MUXER) += yuv4mpeg.o OBJS-$(CONFIG_YUV4MPEGPIPE_DEMUXER) += yuv4mpeg.o # external libraries -OBJS-$(CONFIG_LIBNUT_DEMUXER) += libnut.o riff.o -OBJS-$(CONFIG_LIBNUT_MUXER) += libnut.o riff.o +OBJS-$(CONFIG_LIBNUT_DEMUXER) += libnut.o +OBJS-$(CONFIG_LIBNUT_MUXER) += libnut.o # protocols I/O OBJS+= avio.o aviobuf.o diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 217d8139df..7b67889e73 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1600,6 +1600,30 @@ int av_match_ext(const char *filename, const char *extensions); */ int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance); +/** + * @defgroup riff_fourcc RIFF FourCCs + * @{ + * Get the tables mapping RIFF FourCCs to libavcodec CodecIDs. The tables are + * meant to be passed to av_codec_get_id()/av_codec_get_tag() as in the + * following code: + * @code + * uint32_t tag = MKTAG('H', '2', '6', '4'); + * const struct AVCodecTag *table[] = { avformat_get_riff_video_tags(), 0 }; + * enum CodecID id = av_codec_get_id(table, tag); + * @endcode + */ +/** + * @return the table mapping RIFF FourCCs for video to libavcodec CodecID. + */ +const struct AVCodecTag *avformat_get_riff_video_tags(void); +/** + * @return the table mapping RIFF FourCCs for audio to CodecID. + */ +const struct AVCodecTag *avformat_get_riff_audio_tags(void); +/** + * @} + */ + /** * @} */ diff --git a/libavformat/utils.c b/libavformat/utils.c index cf7180b3cf..e10348df60 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3874,3 +3874,12 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels, } return 0; } + +const struct AVCodecTag *avformat_get_riff_video_tags(void) +{ + return ff_codec_bmp_tags; +} +const struct AVCodecTag *avformat_get_riff_audio_tags(void) +{ + return ff_codec_wav_tags; +} -- cgit v1.2.3