History

lavc: Add properties field to AVCodecContext.

The new field can hold information about losslessness and closed captions for now.

Carl Eugen Hoyos committed 11 years ago

Commit 8dad2131 parent 7aafac99 files · +36 −1Browse files

Unified · Split

9 files
  1. doc/APIchanges +4 −0
  2. libavcodec/avcodec.h +12 −0
  3. libavcodec/h264.c +1 −0
  4. libavcodec/mjpegdec.c +2 −0
  5. libavcodec/mpeg12dec.c +1 −0
  6. libavcodec/utils.c +12 −0
  7. libavcodec/version.h +1 −1
  8. libavcodec/vp9.c +2 −0
  9. libavcodec/webp.c +1 −0
doc/APIchanges+4−0
@@ -15,6 +15,10 @@ libavutil: 2014-08-09 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2015-07-16 - xxxxxxxx - lavc 56.49.100
19+ Add av_codec_get_codec_properties(), FF_CODEC_PROPERTY_LOSSLESS
20+ and FF_CODEC_PROPERTY_CLOSED_CAPTIONS
21+
1822 2015-xx-xx - xxxxxxx - lavu 56.15.0
1923 Add av_version_info().
2024
libavcodec/avcodec.h+12−0
@@ -3173,6 +3173,16 @@ typedef struct AVCodecContext { · 3172 unmodified lines
31733173 * - decoding: set by user through AVOPtions (NO direct access)
31743174 */
31753175 char *codec_whitelist;
3176+
3177+ /*
3178+ * Properties of the stream that gets decoded
3179+ * To be accessed through av_codec_get_properties() (NO direct access)
3180+ * - encoding: unused
3181+ * - decoding: set by libavcodec
3182+ */
3183+ unsigned properties;
3184+#define FF_CODEC_PROPERTY_LOSSLESS 0x00000001
3185+#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002
31763186 } AVCodecContext;
31773187
31783188 AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);
@@ -3181,6 +3191,8 @@ void av_codec_set_pkt_timebase (AVCodecContext *avctx, AVRational · 2 unmodified lines
31813191 const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx);
31823192 void av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc);
31833193
3194+unsigned av_codec_get_codec_properties(const AVCodecContext *avctx);
3195+
31843196 int av_codec_get_lowres(const AVCodecContext *avctx);
31853197 void av_codec_set_lowres(AVCodecContext *avctx, int val);
31863198
libavcodec/h264.c+1−0
@@ -886,6 +886,7 @@ static void decode_postinit(H264Context *h, int setup_finished) · 885 unmodified lines
886886 memcpy(sd->data, h->a53_caption, h->a53_caption_size);
887887 av_freep(&h->a53_caption);
888888 h->a53_caption_size = 0;
889+ h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
889890 }
890891
891892 cur->mmco_reset = h->mmco_reset;
libavcodec/mjpegdec.c+2−0
@@ -2059,6 +2059,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, · 2058 unmodified lines
20592059 goto fail;
20602060 break;
20612061 case SOF3:
2062+ s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
20622063 s->lossless = 1;
20632064 s->ls = 0;
20642065 s->progressive = 0;
@@ -2066,6 +2067,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, · 1 unmodified line
20662067 goto fail;
20672068 break;
20682069 case SOF48:
2070+ s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
20692071 s->lossless = 1;
20702072 s->ls = 1;
20712073 s->progressive = 0;
libavcodec/mpeg12dec.c+1−0
@@ -1685,6 +1685,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) · 1684 unmodified lines
16851685 if (sd)
16861686 memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
16871687 av_freep(&s1->a53_caption);
1688+ avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
16881689 }
16891690
16901691 if (s1->has_stereo3d) {
libavcodec/utils.c+12−0
@@ -1293,6 +1293,11 @@ MAKE_ACCESSORS(AVCodecContext, codec, int, lowres) · 1292 unmodified lines
12931293 MAKE_ACCESSORS(AVCodecContext, codec, int, seek_preroll)
12941294 MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix)
12951295
1296+unsigned av_codec_get_codec_properties(const AVCodecContext *codec)
1297+{
1298+ return codec->properties;
1299+}
1300+
12961301 int av_codec_get_max_lowres(const AVCodec *codec)
12971302 {
12981303 return codec->max_lowres;
@@ -3147,6 +3152,13 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) · 1848 unmodified lines
31473152 if (encode) {
31483153 snprintf(buf + strlen(buf), buf_size - strlen(buf),
31493154 ", q=%d-%d", enc->qmin, enc->qmax);
3155+ } else {
3156+ if (enc->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS)
3157+ snprintf(buf + strlen(buf), buf_size - strlen(buf),
3158+ ", Closed Captions");
3159+ if (enc->properties & FF_CODEC_PROPERTY_LOSSLESS)
3160+ snprintf(buf + strlen(buf), buf_size - strlen(buf),
3161+ ", lossless");
31503162 }
31513163 break;
31523164 case AVMEDIA_TYPE_AUDIO:
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/version.h"
3030
3131 #define LIBAVCODEC_VERSION_MAJOR 56
32−#define LIBAVCODEC_VERSION_MINOR 48
32+#define LIBAVCODEC_VERSION_MINOR 49
3333 #define LIBAVCODEC_VERSION_MICRO 100
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
libavcodec/vp9.c+2−0
@@ -733,6 +733,8 @@ static int decode_frame_header(AVCodecContext *ctx, · 732 unmodified lines
733733 s->uvac_qdelta = get_bits1(&s->gb) ? get_sbits_inv(&s->gb, 4) : 0;
734734 s->lossless = s->yac_qi == 0 && s->ydc_qdelta == 0 &&
735735 s->uvdc_qdelta == 0 && s->uvac_qdelta == 0;
736+ if (s->lossless)
737+ ctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
736738
737739 /* segmentation header info */
738740 s->segmentation.ignore_refmap = 0;
libavcodec/webp.c+1−0
@@ -1417,6 +1417,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, · 1416 unmodified lines
14171417 chunk_size, 0);
14181418 if (ret < 0)
14191419 return ret;
1420+ avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
14201421 }
14211422 bytestream2_skip(&gb, chunk_size);
14221423 break;

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