History

avformat: add support to force specific AVCodecs

previously only codec_ids could be forced, which did not allow forcing a specific implementation like libopenjpeg vs jpeg2000.

Michael Niedermayer committed 13 years ago

Commit 5082fcc1 parent f4aec344 files · +51 −2Browse files

Unified · Split

4 files
  1. doc/APIchanges +4 −0
  2. libavformat/avformat.h +30 −0
  3. libavformat/utils.c +15 −0
  4. libavformat/version.h +2 −2
doc/APIchanges+4−0
@@ -15,6 +15,10 @@ libavutil: 2012-10-22 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2013-10-02 - xxxxxxx - lavf 55.19.100 - avformat.h
19+ Add audio/video/subtitle AVCodec fields to AVFormatContext to force specific
20+ decoders
21+
1822 2013-08-xx - xxxxxxx - lavfi 3.11.0 - avfilter.h
1923 Add AVFilterGraph.execute and AVFilterGraph.opaque for custom slice threading
2024 implementations.
libavformat/avformat.h+30−0
@@ -1315,9 +1315,39 @@ typedef struct AVFormatContext { · 1314 unmodified lines
13151315 * Demuxers can use the flag to detect such changes.
13161316 */
13171317 int io_repositioned;
1318+
1319+ /**
1320+ * Forced video codec.
1321+ * This allows forcing a specific decoder, even when there are multiple with
1322+ * the same codec_id.
1323+ * Demuxing: Set by user via av_format_set_video_codec (NO direct access).
1324+ */
1325+ AVCodec *video_codec;
1326+
1327+ /**
1328+ * Forced audio codec.
1329+ * This allows forcing a specific decoder, even when there are multiple with
1330+ * the same codec_id.
1331+ * Demuxing: Set by user via av_format_set_audio_codec (NO direct access).
1332+ */
1333+ AVCodec *audio_codec;
1334+
1335+ /**
1336+ * Forced subtitle codec.
1337+ * This allows forcing a specific decoder, even when there are multiple with
1338+ * the same codec_id.
1339+ * Demuxing: Set by user via av_format_set_subtitle_codec (NO direct access).
1340+ */
1341+ AVCodec *subtitle_codec;
13181342 } AVFormatContext;
13191343
13201344 int av_format_get_probe_score(const AVFormatContext *s);
1345+AVCodec * av_format_get_video_codec(const AVFormatContext *s);
1346+void av_format_set_video_codec(AVFormatContext *s, AVCodec *c);
1347+AVCodec * av_format_get_audio_codec(const AVFormatContext *s);
1348+void av_format_set_audio_codec(AVFormatContext *s, AVCodec *c);
1349+AVCodec * av_format_get_subtitle_codec(const AVFormatContext *s);
1350+void av_format_set_subtitle_codec(AVFormatContext *s, AVCodec *c);
13211351
13221352 /**
13231353 * Returns the method used to set ctx->duration.
libavformat/utils.c+15−0
@@ -98,12 +98,27 @@ static int64_t wrap_timestamp(AVStream *st, int64_t timestamp) · 97 unmodified lines
9898 }
9999
100100 MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate)
101+MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec)
102+MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, audio_codec)
103+MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
101104
102105 static AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)
103106 {
104107 if (st->codec->codec)
105108 return st->codec->codec;
106109
110+ switch(st->codec->codec_type){
111+ case AVMEDIA_TYPE_VIDEO:
112+ if(s->video_codec) return s->video_codec;
113+ break;
114+ case AVMEDIA_TYPE_AUDIO:
115+ if(s->audio_codec) return s->audio_codec;
116+ break;
117+ case AVMEDIA_TYPE_SUBTITLE:
118+ if(s->subtitle_codec) return s->subtitle_codec;
119+ break;
120+ }
121+
107122 return avcodec_find_decoder(codec_id);
108123 }
109124
libavformat/version.h+2−2
@@ -30,8 +30,8 @@ · 29 unmodified lines
3030 #include "libavutil/avutil.h"
3131
3232 #define LIBAVFORMAT_VERSION_MAJOR 55
33−#define LIBAVFORMAT_VERSION_MINOR 18
34−#define LIBAVFORMAT_VERSION_MICRO 104
33+#define LIBAVFORMAT_VERSION_MINOR 19
34+#define LIBAVFORMAT_VERSION_MICRO 100
3535
3636 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3737 LIBAVFORMAT_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t