summaryrefslogtreecommitdiff
path: root/libavcodec/hevcdec.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-05-07 10:51:58 -0300
committerLuca Barbato <lu_zero@gentoo.org>2017-05-09 13:42:20 +0200
commit648a0b450387d535567a1569cabb9e3dbe08a3e5 (patch)
tree1d82929e1742a36a850bc2448e98f67aab28005a /libavcodec/hevcdec.c
parent59cee42d7d22530e66a155305389e29679b11f78 (diff)
hevcdec: remove HEVCContext usage from hevc_sei
Based on the H264 SEI implementation. This will be mainly useful once support for SEI messages that can be used by the hevc parser are implemented, like Picture Timing. Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavcodec/hevcdec.c')
-rw-r--r--libavcodec/hevcdec.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 6a04858587..96e47cd187 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2362,18 +2362,18 @@ static int set_side_data(HEVCContext *s)
{
AVFrame *out = s->ref->frame;
- if (s->sei_frame_packing_present &&
- s->frame_packing_arrangement_type >= 3 &&
- s->frame_packing_arrangement_type <= 5 &&
- s->content_interpretation_type > 0 &&
- s->content_interpretation_type < 3) {
+ if (s->sei.frame_packing.present &&
+ s->sei.frame_packing.arrangement_type >= 3 &&
+ s->sei.frame_packing.arrangement_type <= 5 &&
+ s->sei.frame_packing.content_interpretation_type > 0 &&
+ s->sei.frame_packing.content_interpretation_type < 3) {
AVStereo3D *stereo = av_stereo3d_create_side_data(out);
if (!stereo)
return AVERROR(ENOMEM);
- switch (s->frame_packing_arrangement_type) {
+ switch (s->sei.frame_packing.arrangement_type) {
case 3:
- if (s->quincunx_subsampling)
+ if (s->sei.frame_packing.quincunx_subsampling)
stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
else
stereo->type = AV_STEREO3D_SIDEBYSIDE;
@@ -2386,13 +2386,14 @@ static int set_side_data(HEVCContext *s)
break;
}
- if (s->content_interpretation_type == 2)
+ if (s->sei.frame_packing.content_interpretation_type == 2)
stereo->flags = AV_STEREO3D_FLAG_INVERT;
}
- if (s->sei_display_orientation_present &&
- (s->sei_anticlockwise_rotation || s->sei_hflip || s->sei_vflip)) {
- double angle = s->sei_anticlockwise_rotation * 360 / (double) (1 << 16);
+ if (s->sei.display_orientation.present &&
+ (s->sei.display_orientation.anticlockwise_rotation ||
+ s->sei.display_orientation.hflip || s->sei.display_orientation.vflip)) {
+ double angle = s->sei.display_orientation.anticlockwise_rotation * 360 / (double) (1 << 16);
AVFrameSideData *rotation = av_frame_new_side_data(out,
AV_FRAME_DATA_DISPLAYMATRIX,
sizeof(int32_t) * 9);
@@ -2401,7 +2402,8 @@ static int set_side_data(HEVCContext *s)
av_display_rotation_set((int32_t *)rotation->data, angle);
av_display_matrix_flip((int32_t *)rotation->data,
- s->sei_hflip, s->sei_vflip);
+ s->sei.display_orientation.hflip,
+ s->sei.display_orientation.vflip);
}
return 0;
@@ -2486,7 +2488,8 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
break;
case HEVC_NAL_SEI_PREFIX:
case HEVC_NAL_SEI_SUFFIX:
- ret = ff_hevc_decode_nal_sei(s);
+ ret = ff_hevc_decode_nal_sei(gb, s->avctx, &s->sei,
+ s->nal_unit_type);
if (ret < 0)
goto fail;
break;
@@ -2680,7 +2683,7 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
int h = (i == 1 || i == 2) ? (height >> desc->log2_chroma_h) : height;
uint8_t md5[16];
- av_md5_init(s->md5_ctx);
+ av_md5_init(s->sei.picture_hash.md5_ctx);
for (j = 0; j < h; j++) {
const uint8_t *src = frame->data[i] + j * frame->linesize[i];
#if HAVE_BIGENDIAN
@@ -2690,11 +2693,11 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
src = s->checksum_buf;
}
#endif
- av_md5_update(s->md5_ctx, src, w << pixel_shift);
+ av_md5_update(s->sei.picture_hash.md5_ctx, src, w << pixel_shift);
}
- av_md5_final(s->md5_ctx, md5);
+ av_md5_final(s->sei.picture_hash.md5_ctx, md5);
- if (!memcmp(md5, s->md5[i], 16)) {
+ if (!memcmp(md5, s->sei.picture_hash.md5[i], 16)) {
av_log (s->avctx, AV_LOG_DEBUG, "plane %d - correct ", i);
print_md5(s->avctx, AV_LOG_DEBUG, md5);
av_log (s->avctx, AV_LOG_DEBUG, "; ");
@@ -2702,7 +2705,7 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
av_log (s->avctx, AV_LOG_ERROR, "mismatching checksum of plane %d - ", i);
print_md5(s->avctx, AV_LOG_ERROR, md5);
av_log (s->avctx, AV_LOG_ERROR, " != ");
- print_md5(s->avctx, AV_LOG_ERROR, s->md5[i]);
+ print_md5(s->avctx, AV_LOG_ERROR, s->sei.picture_hash.md5[i]);
av_log (s->avctx, AV_LOG_ERROR, "\n");
return AVERROR_INVALIDDATA;
}
@@ -2822,7 +2825,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
} else {
/* verify the SEI checksum */
if (avctx->err_recognition & AV_EF_CRCCHECK && s->is_decoded &&
- s->is_md5) {
+ s->sei.picture_hash.is_md5) {
ret = verify_md5(s, s->ref->frame);
if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE) {
ff_hevc_unref_frame(s, s->ref, ~0);
@@ -2830,7 +2833,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
}
}
}
- s->is_md5 = 0;
+ s->sei.picture_hash.is_md5 = 0;
if (s->is_decoded) {
av_log(avctx, AV_LOG_DEBUG, "Decoded frame with POC %d.\n", s->poc);
@@ -2890,7 +2893,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
pic_arrays_free(s);
- av_freep(&s->md5_ctx);
+ av_freep(&s->sei.picture_hash.md5_ctx);
av_frame_free(&s->tmp_frame);
av_frame_free(&s->output_frame);
@@ -2936,8 +2939,8 @@ static av_cold int hevc_init_context(AVCodecContext *avctx)
s->max_ra = INT_MAX;
- s->md5_ctx = av_md5_alloc();
- if (!s->md5_ctx)
+ s->sei.picture_hash.md5_ctx = av_md5_alloc();
+ if (!s->sei.picture_hash.md5_ctx)
goto fail;
ff_bswapdsp_init(&s->bdsp);