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
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182013-10-02 - xxxxxxx - lavf 55.19.100 - avformat.h
19 Add audio/video/subtitle AVCodec fields to AVFormatContext to force specific
20 decoders
21
182013-08-xx - xxxxxxx - lavfi 3.11.0 - avfilter.h222013-08-xx - xxxxxxx - lavfi 3.11.0 - avfilter.h
19 Add AVFilterGraph.execute and AVFilterGraph.opaque for custom slice threading23 Add AVFilterGraph.execute and AVFilterGraph.opaque for custom slice threading
20 implementations.24 implementations.
libavformat/avformat.h+30−0
@@ -1315,9 +1315,39 @@ typedef struct AVFormatContext { · 1314 unmodified lines
1315 * Demuxers can use the flag to detect such changes.1315 * Demuxers can use the flag to detect such changes.
1316 */1316 */
1317 int io_repositioned;1317 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;
1318} AVFormatContext;1342} AVFormatContext;
1319 1343
1320int av_format_get_probe_score(const AVFormatContext *s);1344int av_format_get_probe_score(const AVFormatContext *s);
1345AVCodec * av_format_get_video_codec(const AVFormatContext *s);
1346void av_format_set_video_codec(AVFormatContext *s, AVCodec *c);
1347AVCodec * av_format_get_audio_codec(const AVFormatContext *s);
1348void av_format_set_audio_codec(AVFormatContext *s, AVCodec *c);
1349AVCodec * av_format_get_subtitle_codec(const AVFormatContext *s);
1350void av_format_set_subtitle_codec(AVFormatContext *s, AVCodec *c);
1321 1351
1322/**1352/**
1323 * Returns the method used to set ctx->duration.1353 * 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
98}98}
99 99
100MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate)100MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate)
101MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec)
102MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, audio_codec)
103MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
101 104
102static AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)105static AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)
103{106{
104 if (st->codec->codec)107 if (st->codec->codec)
105 return st->codec->codec;108 return st->codec->codec;
106 109
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
107 return avcodec_find_decoder(codec_id);122 return avcodec_find_decoder(codec_id);
108}123}
109 124
libavformat/version.h+2−2
@@ -30,8 +30,8 @@ · 29 unmodified lines
30#include "libavutil/avutil.h"30#include "libavutil/avutil.h"
31 31
32#define LIBAVFORMAT_VERSION_MAJOR 5532#define LIBAVFORMAT_VERSION_MAJOR 55
33#define LIBAVFORMAT_VERSION_MINOR 1833#define LIBAVFORMAT_VERSION_MINOR 19
34#define LIBAVFORMAT_VERSION_MICRO 10434#define LIBAVFORMAT_VERSION_MICRO 100
35 35
36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
37 LIBAVFORMAT_VERSION_MINOR, \37 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