History

lavc: make codec_is_decoder/encoder() public.

Anton Khirnov committed 14 years ago

Commit 44fe77b1 parent 02beb984 files · +23 −10Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavcodec/avcodec.h +10 −0
  3. libavcodec/utils.c +9 −9
  4. libavcodec/version.h +1 −1
doc/APIchanges+3−0
@@ -12,6 +12,9 @@ libavutil: 2011-04-18 · 11 unmodified lines
12 12
13API changes, most recent first:13API changes, most recent first:
14 14
152012-03-xx - xxxxxxx - lavc 54.7.0 - avcodec.h
16 Add av_codec_is_encoder/decoder().
17
152012-xx-xx - xxxxxxx - lavc 54.3.0 - avcodec.h182012-xx-xx - xxxxxxx - lavc 54.3.0 - avcodec.h
16 Add av_packet_shrink_side_data.19 Add av_packet_shrink_side_data.
17 20
libavcodec/avcodec.h+10−0
@@ -4297,4 +4297,14 @@ const AVClass *avcodec_get_class(void); · 4296 unmodified lines
4297 */4297 */
4298int avcodec_is_open(AVCodecContext *s);4298int avcodec_is_open(AVCodecContext *s);
4299 4299
4300/**
4301 * @return a non-zero number if codec is an encoder, zero otherwise
4302 */
4303int av_codec_is_encoder(AVCodec *codec);
4304
4305/**
4306 * @return a non-zero number if codec is a decoder, zero otherwise
4307 */
4308int av_codec_is_decoder(AVCodec *codec);
4309
4300#endif /* AVCODEC_AVCODEC_H */4310#endif /* AVCODEC_AVCODEC_H */
libavcodec/utils.c+9−9
@@ -112,12 +112,12 @@ static void avcodec_init(void) · 111 unmodified lines
112 ff_dsputil_static_init();112 ff_dsputil_static_init();
113}113}
114 114
115static av_always_inline int codec_is_encoder(AVCodec *codec)115int av_codec_is_encoder(AVCodec *codec)
116{116{
117 return codec && (codec->encode || codec->encode2);117 return codec && (codec->encode || codec->encode2);
118}118}
119 119
120static av_always_inline int codec_is_decoder(AVCodec *codec)120int av_codec_is_decoder(AVCodec *codec)
121{121{
122 return codec && codec->decode;122 return codec && codec->decode;
123}123}
@@ -704,7 +704,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD · 580 unmodified lines
704 704
705 /* if the decoder init function was already called previously,705 /* if the decoder init function was already called previously,
706 free the already allocated subtitle_header before overwriting it */706 free the already allocated subtitle_header before overwriting it */
707 if (codec_is_decoder(codec))707 if (av_codec_is_decoder(codec))
708 av_freep(&avctx->subtitle_header);708 av_freep(&avctx->subtitle_header);
709 709
710#define SANE_NB_CHANNELS 128U710#define SANE_NB_CHANNELS 128U
@@ -748,7 +748,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD · 37 unmodified lines
748 ret = AVERROR(EINVAL);748 ret = AVERROR(EINVAL);
749 goto free_and_end;749 goto free_and_end;
750 }750 }
751 if (codec_is_encoder(avctx->codec)) {751 if (av_codec_is_encoder(avctx->codec)) {
752 int i;752 int i;
753 if (avctx->codec->sample_fmts) {753 if (avctx->codec->sample_fmts) {
754 for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)754 for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
@@ -1367,7 +1367,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) · 612 unmodified lines
1367 av_opt_free(avctx->priv_data);1367 av_opt_free(avctx->priv_data);
1368 av_opt_free(avctx);1368 av_opt_free(avctx);
1369 av_freep(&avctx->priv_data);1369 av_freep(&avctx->priv_data);
1370 if (codec_is_encoder(avctx->codec))1370 if (av_codec_is_encoder(avctx->codec))
1371 av_freep(&avctx->extradata);1371 av_freep(&avctx->extradata);
1372 avctx->codec = NULL;1372 avctx->codec = NULL;
1373 avctx->active_thread_type = 0;1373 avctx->active_thread_type = 0;
@@ -1385,7 +1385,7 @@ AVCodec *avcodec_find_encoder(enum CodecID id) · 11 unmodified lines
1385 AVCodec *p, *experimental=NULL;1385 AVCodec *p, *experimental=NULL;
1386 p = first_avcodec;1386 p = first_avcodec;
1387 while (p) {1387 while (p) {
1388 if (codec_is_encoder(p) && p->id == id) {1388 if (av_codec_is_encoder(p) && p->id == id) {
1389 if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) {1389 if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) {
1390 experimental = p;1390 experimental = p;
1391 } else1391 } else
@@ -1403,7 +1403,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name) · 11 unmodified lines
1403 return NULL;1403 return NULL;
1404 p = first_avcodec;1404 p = first_avcodec;
1405 while (p) {1405 while (p) {
1406 if (codec_is_encoder(p) && strcmp(name,p->name) == 0)1406 if (av_codec_is_encoder(p) && strcmp(name,p->name) == 0)
1407 return p;1407 return p;
1408 p = p->next;1408 p = p->next;
1409 }1409 }
@@ -1415,7 +1415,7 @@ AVCodec *avcodec_find_decoder(enum CodecID id) · 5 unmodified lines
1415 AVCodec *p;1415 AVCodec *p;
1416 p = first_avcodec;1416 p = first_avcodec;
1417 while (p) {1417 while (p) {
1418 if (codec_is_decoder(p) && p->id == id)1418 if (av_codec_is_decoder(p) && p->id == id)
1419 return p;1419 return p;
1420 p = p->next;1420 p = p->next;
1421 }1421 }
@@ -1429,7 +1429,7 @@ AVCodec *avcodec_find_decoder_by_name(const char *name) · 7 unmodified lines
1429 return NULL;1429 return NULL;
1430 p = first_avcodec;1430 p = first_avcodec;
1431 while (p) {1431 while (p) {
1432 if (codec_is_decoder(p) && strcmp(name,p->name) == 0)1432 if (av_codec_is_decoder(p) && strcmp(name,p->name) == 0)
1433 return p;1433 return p;
1434 p = p->next;1434 p = p->next;
1435 }1435 }
libavcodec/version.h+1−1
@@ -21,7 +21,7 @@ · 20 unmodified lines
21#define AVCODEC_VERSION_H21#define AVCODEC_VERSION_H
22 22
23#define LIBAVCODEC_VERSION_MAJOR 5423#define LIBAVCODEC_VERSION_MAJOR 54
24#define LIBAVCODEC_VERSION_MINOR 624#define LIBAVCODEC_VERSION_MINOR 7
25#define LIBAVCODEC_VERSION_MICRO 025#define LIBAVCODEC_VERSION_MICRO 0
26 26
27#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \27#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

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