summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <cehoyos@ag.or.at>2015-07-16 09:47:55 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-16 12:18:30 +0200
commit8dad213143e34b477f034ada4addf2ed2b1c983d (patch)
tree9bc4101735fa4a55d58003abf00f662b09d76c87 /libavcodec
parent7aafac976fe2806c9519d4154b5f0d5b6767fbe2 (diff)
lavc: Add properties field to AVCodecContext.
The new field can hold information about losslessness and closed captions for now.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h12
-rw-r--r--libavcodec/h264.c1
-rw-r--r--libavcodec/mjpegdec.c2
-rw-r--r--libavcodec/mpeg12dec.c1
-rw-r--r--libavcodec/utils.c12
-rw-r--r--libavcodec/version.h2
-rw-r--r--libavcodec/vp9.c2
-rw-r--r--libavcodec/webp.c1
8 files changed, 32 insertions, 1 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 738f4db9cb..ad2f5b56eb 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 f62ad6a2f3..eb834f13b4 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 8094274ff6..cc82a43c3b 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 7fad75386c..480cf41f67 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 07017863fb..e4eb772f4c 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 df58e0a604..778293af00 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 6888326a05..5b5ad9966e 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 723a84769b..8caa6a2c7f 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;