[FFmpeg-cvslog] lavc: Add properties field to AVCodecContext.

Carl Eugen Hoyos git at videolan.org
Thu Jul 16 12:28:17 CEST 2015


ffmpeg | branch: master | Carl Eugen Hoyos <cehoyos at ag.or.at> | Thu Jul 16 09:47:55 2015 +0200| [8dad213143e34b477f034ada4addf2ed2b1c983d] | committer: Michael Niedermayer

lavc: Add properties field to AVCodecContext.

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

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8dad213143e34b477f034ada4addf2ed2b1c983d
---

 doc/APIchanges         |    4 ++++
 libavcodec/avcodec.h   |   12 ++++++++++++
 libavcodec/h264.c      |    1 +
 libavcodec/mjpegdec.c  |    2 ++
 libavcodec/mpeg12dec.c |    1 +
 libavcodec/utils.c     |   12 ++++++++++++
 libavcodec/version.h   |    2 +-
 libavcodec/vp9.c       |    2 ++
 libavcodec/webp.c      |    1 +
 9 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 12d607d..340515c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+2015-07-16 - xxxxxxxx - lavc 56.49.100
+  Add av_codec_get_codec_properties(), FF_CODEC_PROPERTY_LOSSLESS
+  and FF_CODEC_PROPERTY_CLOSED_CAPTIONS
+
 2015-xx-xx - xxxxxxx - lavu 56.15.0
   Add av_version_info().
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 738f4db..ad2f5b5 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3173,6 +3173,16 @@ typedef struct AVCodecContext {
      * - decoding: set by user through AVOPtions (NO direct access)
      */
     char *codec_whitelist;
+
+    /*
+     * Properties of the stream that gets decoded
+     * To be accessed through av_codec_get_properties() (NO direct access)
+     * - encoding: unused
+     * - decoding: set by libavcodec
+     */
+    unsigned properties;
+#define FF_CODEC_PROPERTY_LOSSLESS        0x00000001
+#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002
 } AVCodecContext;
 
 AVRational av_codec_get_pkt_timebase         (const AVCodecContext *avctx);
@@ -3181,6 +3191,8 @@ void       av_codec_set_pkt_timebase         (AVCodecContext *avctx, AVRational
 const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx);
 void                     av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc);
 
+unsigned av_codec_get_codec_properties(const AVCodecContext *avctx);
+
 int  av_codec_get_lowres(const AVCodecContext *avctx);
 void av_codec_set_lowres(AVCodecContext *avctx, int val);
 
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index f62ad6a..eb834f1 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -886,6 +886,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
             memcpy(sd->data, h->a53_caption, h->a53_caption_size);
         av_freep(&h->a53_caption);
         h->a53_caption_size = 0;
+        h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
     }
 
     cur->mmco_reset = h->mmco_reset;
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 8094274..cc82a43 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2059,6 +2059,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
                 goto fail;
             break;
         case SOF3:
+            s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
             s->lossless    = 1;
             s->ls          = 0;
             s->progressive = 0;
@@ -2066,6 +2067,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
                 goto fail;
             break;
         case SOF48:
+            s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
             s->lossless    = 1;
             s->ls          = 1;
             s->progressive = 0;
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 7fad753..480cf41 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1685,6 +1685,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
             if (sd)
                 memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
             av_freep(&s1->a53_caption);
+            avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
         }
 
         if (s1->has_stereo3d) {
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 0701786..e4eb772 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1293,6 +1293,11 @@ MAKE_ACCESSORS(AVCodecContext, codec, int, lowres)
 MAKE_ACCESSORS(AVCodecContext, codec, int, seek_preroll)
 MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix)
 
+unsigned av_codec_get_codec_properties(const AVCodecContext *codec)
+{
+    return codec->properties;
+}
+
 int av_codec_get_max_lowres(const AVCodec *codec)
 {
     return codec->max_lowres;
@@ -3147,6 +3152,13 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
         if (encode) {
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
                      ", q=%d-%d", enc->qmin, enc->qmax);
+        } else {
+            if (enc->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS)
+                snprintf(buf + strlen(buf), buf_size - strlen(buf),
+                         ", Closed Captions");
+            if (enc->properties & FF_CODEC_PROPERTY_LOSSLESS)
+                snprintf(buf + strlen(buf), buf_size - strlen(buf),
+                         ", lossless");
         }
         break;
     case AVMEDIA_TYPE_AUDIO:
diff --git a/libavcodec/version.h b/libavcodec/version.h
index df58e0a..778293a 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 56
-#define LIBAVCODEC_VERSION_MINOR  48
+#define LIBAVCODEC_VERSION_MINOR  49
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 6888326..5b5ad99 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -733,6 +733,8 @@ static int decode_frame_header(AVCodecContext *ctx,
     s->uvac_qdelta = get_bits1(&s->gb) ? get_sbits_inv(&s->gb, 4) : 0;
     s->lossless    = s->yac_qi == 0 && s->ydc_qdelta == 0 &&
                      s->uvdc_qdelta == 0 && s->uvac_qdelta == 0;
+    if (s->lossless)
+        ctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
 
     /* segmentation header info */
     s->segmentation.ignore_refmap = 0;
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 723a847..8caa6a2 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1417,6 +1417,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
                                                 chunk_size, 0);
                 if (ret < 0)
                     return ret;
+                avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
             }
             bytestream2_skip(&gb, chunk_size);
             break;



More information about the ffmpeg-cvslog mailing list