OSDN Git Service

avformat: add support to force specific AVCodecs
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 28 Sep 2013 15:52:45 +0000 (17:52 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 2 Oct 2013 20:56:03 +0000 (22:56 +0200)
previously only codec_ids could be forced, which did not allow
forcing a specific implementation like libopenjpeg vs jpeg2000.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
doc/APIchanges
libavformat/avformat.h
libavformat/utils.c
libavformat/version.h

index ab932c3..743b5b0 100644 (file)
@@ -15,6 +15,10 @@ libavutil:     2012-10-22
 
 API changes, most recent first:
 
+2013-10-02 - xxxxxxx - lavf 55.19.100 - avformat.h
+  Add audio/video/subtitle AVCodec fields to AVFormatContext to force specific
+  decoders
+
 2013-08-xx - xxxxxxx - lavfi 3.11.0 - avfilter.h
   Add AVFilterGraph.execute and AVFilterGraph.opaque for custom slice threading
   implementations.
index b18eb3f..4e5683c 100644 (file)
@@ -1315,9 +1315,39 @@ typedef struct AVFormatContext {
      * Demuxers can use the flag to detect such changes.
      */
     int io_repositioned;
+
+    /**
+     * Forced video codec.
+     * This allows forcing a specific decoder, even when there are multiple with
+     * the same codec_id.
+     * Demuxing: Set by user via av_format_set_video_codec (NO direct access).
+     */
+    AVCodec *video_codec;
+
+    /**
+     * Forced audio codec.
+     * This allows forcing a specific decoder, even when there are multiple with
+     * the same codec_id.
+     * Demuxing: Set by user via av_format_set_audio_codec (NO direct access).
+     */
+    AVCodec *audio_codec;
+
+    /**
+     * Forced subtitle codec.
+     * This allows forcing a specific decoder, even when there are multiple with
+     * the same codec_id.
+     * Demuxing: Set by user via av_format_set_subtitle_codec (NO direct access).
+     */
+    AVCodec *subtitle_codec;
 } AVFormatContext;
 
 int av_format_get_probe_score(const AVFormatContext *s);
+AVCodec * av_format_get_video_codec(const AVFormatContext *s);
+void      av_format_set_video_codec(AVFormatContext *s, AVCodec *c);
+AVCodec * av_format_get_audio_codec(const AVFormatContext *s);
+void      av_format_set_audio_codec(AVFormatContext *s, AVCodec *c);
+AVCodec * av_format_get_subtitle_codec(const AVFormatContext *s);
+void      av_format_set_subtitle_codec(AVFormatContext *s, AVCodec *c);
 
 /**
  * Returns the method used to set ctx->duration.
index b47787a..61405d7 100644 (file)
@@ -98,12 +98,27 @@ static int64_t wrap_timestamp(AVStream *st, int64_t timestamp)
 }
 
 MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate)
+MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec)
+MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, audio_codec)
+MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
 
 static AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)
 {
     if (st->codec->codec)
         return st->codec->codec;
 
+    switch(st->codec->codec_type){
+    case AVMEDIA_TYPE_VIDEO:
+        if(s->video_codec)    return s->video_codec;
+        break;
+    case AVMEDIA_TYPE_AUDIO:
+        if(s->audio_codec)    return s->audio_codec;
+        break;
+    case AVMEDIA_TYPE_SUBTITLE:
+        if(s->subtitle_codec) return s->subtitle_codec;
+        break;
+    }
+
     return avcodec_find_decoder(codec_id);
 }
 
index 10b6a36..32e76c7 100644 (file)
@@ -30,8 +30,8 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 55
-#define LIBAVFORMAT_VERSION_MINOR 18
-#define LIBAVFORMAT_VERSION_MICRO 104
+#define LIBAVFORMAT_VERSION_MINOR 19
+#define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \