summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2007-12-19 10:56:17 +0000
committerMichael Niedermayer <michaelni@gmx.at>2007-12-19 10:56:17 +0000
commit626004690c23c981f67228ea325dde3f35193988 (patch)
tree4c83eca851de2f715b7dcbd8a11b113d9422c516 /libavformat
parent379374ea11ea561729fc0c6dc38a06f9b5b43731 (diff)
Allow overriding codec_ids.
Originally committed as revision 11266 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avformat.h16
-rw-r--r--libavformat/utils.c19
2 files changed, 34 insertions, 1 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index ad8dc7d6aa..27d3c00370 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -445,6 +445,22 @@ typedef struct AVFormatContext {
unsigned int nb_programs;
AVProgram **programs;
+
+ /**
+ * Forced video codec_id.
+ * demuxing: set by user
+ */
+ enum CodecID video_codec_id;
+ /**
+ * Forced audio codec_id.
+ * demuxing: set by user
+ */
+ enum CodecID audio_codec_id;
+ /**
+ * Forced subtitle codec_id.
+ * demuxing: set by user
+ */
+ enum CodecID subtitle_codec_id;
} AVFormatContext;
typedef struct AVPacketList {
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 1a34049c21..386fe60718 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -493,8 +493,25 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
int av_read_packet(AVFormatContext *s, AVPacket *pkt)
{
+ int ret;
+ AVStream *st;
av_init_packet(pkt);
- return s->iformat->read_packet(s, pkt);
+ ret= s->iformat->read_packet(s, pkt);
+ st= s->streams[pkt->stream_index];
+
+ switch(st->codec->codec_type){
+ case CODEC_TYPE_VIDEO:
+ if(s->video_codec_id) st->codec->codec_id= s->video_codec_id;
+ break;
+ case CODEC_TYPE_AUDIO:
+ if(s->audio_codec_id) st->codec->codec_id= s->audio_codec_id;
+ break;
+ case CODEC_TYPE_SUBTITLE:
+ if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id;
+ break;
+ }
+
+ return ret;
}
/**********************************************************/