changeset 2832:8ac5fe1c5549 libavformat

Allow overriding codec_ids.
author michael
date Wed, 19 Dec 2007 10:56:17 +0000
parents e89500ae1608
children 578a0c783eae
files avformat.h utils.c
diffstat 2 files changed, 34 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/avformat.h	Wed Dec 19 02:33:47 2007 +0000
+++ b/avformat.h	Wed Dec 19 10:56:17 2007 +0000
@@ -445,6 +445,22 @@
 
     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 {
--- a/utils.c	Wed Dec 19 02:33:47 2007 +0000
+++ b/utils.c	Wed Dec 19 10:56:17 2007 +0000
@@ -493,8 +493,25 @@
 
 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;
 }
 
 /**********************************************************/