Commit 8dad2131 authored by Carl Eugen Hoyos's avatar Carl Eugen Hoyos Committed by Michael Niedermayer

lavc: Add properties field to AVCodecContext.

The new field can hold information about losslessness and closed captions for now.
parent 7aafac97
......@@ -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().
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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:
......
......@@ -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, \
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment