static int verify_md5(HEVCContext *s, AVFrame *frame)

{

    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);

    int pixel_shift = desc->comp[0].depth_minus1 > 7;

    int i, j;



    if (!desc)

        return AVERROR(EINVAL);



    av_log(s->avctx, AV_LOG_DEBUG, "Verifying checksum for frame with POC %d: ",

           s->poc);



    /* the checksums are LE, so we have to byteswap for >8bpp formats

     * on BE arches */

#if HAVE_BIGENDIAN

    if (pixel_shift && !s->checksum_buf) {

        av_fast_malloc(&s->checksum_buf, &s->checksum_buf_size,

                       FFMAX3(frame->linesize[0], frame->linesize[1],

                              frame->linesize[2]));

        if (!s->checksum_buf)

            return AVERROR(ENOMEM);

    }

#endif



    for (i = 0; frame->data[i]; i++) {

        int width  = s->avctx->coded_width;

        int height = s->avctx->coded_height;

        int w = (i == 1 || i == 2) ? (width  >> desc->log2_chroma_w) : width;

        int h = (i == 1 || i == 2) ? (height >> desc->log2_chroma_h) : height;

        uint8_t md5[16];



        av_md5_init(s->md5_ctx);

        for (j = 0; j < h; j++) {

            const uint8_t *src = frame->data[i] + j * frame->linesize[i];

#if HAVE_BIGENDIAN

            if (pixel_shift) {

                s->dsp.bswap16_buf((uint16_t*)s->checksum_buf,

                                   (const uint16_t*)src, w);

                src = s->checksum_buf;

            }

#endif

            av_md5_update(s->md5_ctx, src, w << pixel_shift);

        }

        av_md5_final(s->md5_ctx, md5);



        if (!memcmp(md5, s->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, "; ");

        } else {

            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]);

            av_log   (s->avctx, AV_LOG_ERROR, "\n");

            return AVERROR_INVALIDDATA;

        }

    }



    av_log(s->avctx, AV_LOG_DEBUG, "\n");



    return 0;

}

static int verify_md5(HEVCContext *s, AVFrame *frame)

{

    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);

    int pixel_shift = desc->comp[0].depth_minus1 > 7;

    int i, j;



    if (!desc)

        return AVERROR(EINVAL);



    av_log(s->avctx, AV_LOG_DEBUG, "Verifying checksum for frame with POC %d: ",

           s->poc);



    



#if HAVE_BIGENDIAN

    if (pixel_shift && !s->checksum_buf) {

        av_fast_malloc(&s->checksum_buf, &s->checksum_buf_size,

                       FFMAX3(frame->linesize[0], frame->linesize[1],

                              frame->linesize[2]));

        if (!s->checksum_buf)

            return AVERROR(ENOMEM);

    }

#endif



    for (i = 0; frame->data[i]; i++) {

        int width  = s->avctx->coded_width;

        int height = s->avctx->coded_height;

        int w = (i == 1 || i == 2) ? (width  >> desc->log2_chroma_w) : width;

        int h = (i == 1 || i == 2) ? (height >> desc->log2_chroma_h) : height;

        uint8_t md5[16];



        av_md5_init(s->md5_ctx);

        for (j = 0; j < h; j++) {

            const uint8_t *src = frame->data[i] + j * frame->linesize[i];

#if HAVE_BIGENDIAN

            if (pixel_shift) {

                s->dsp.bswap16_buf((uint16_t*)s->checksum_buf,

                                   (const uint16_t*)src, w);

                src = s->checksum_buf;

            }

#endif

            av_md5_update(s->md5_ctx, src, w << pixel_shift);

        }

        av_md5_final(s->md5_ctx, md5);



        if (!memcmp(md5, s->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, "; ");

        } else {

            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]);

            av_log   (s->avctx, AV_LOG_ERROR, "\n");

            return AVERROR_INVALIDDATA;

        }

    }



    av_log(s->avctx, AV_LOG_DEBUG, "\n");



    return 0;

}

    int pixel_shift = desc->comp[0].depth_minus1 > 7;
static int FUNC_0(HEVCContext *VAR_0, AVFrame *VAR_1)

{

    const AVPixFmtDescriptor *VAR_2 = av_pix_fmt_desc_get(VAR_1->format);

    int VAR_3 = VAR_2->comp[0].depth_minus1 > 7;

    int VAR_4, VAR_5;



    if (!VAR_2)

        return AVERROR(EINVAL);



    av_log(VAR_0->avctx, AV_LOG_DEBUG, "Verifying checksum for VAR_1 with POC %d: ",

           VAR_0->poc);



    



#if HAVE_BIGENDIAN

    if (VAR_3 && !VAR_0->checksum_buf) {

        av_fast_malloc(&VAR_0->checksum_buf, &VAR_0->checksum_buf_size,

                       FFMAX3(VAR_1->linesize[0], VAR_1->linesize[1],

                              VAR_1->linesize[2]));

        if (!VAR_0->checksum_buf)

            return AVERROR(ENOMEM);

    }

#endif



    for (VAR_4 = 0; VAR_1->data[VAR_4]; VAR_4++) {

        int width  = VAR_0->avctx->coded_width;

        int height = VAR_0->avctx->coded_height;

        int w = (VAR_4 == 1 || VAR_4 == 2) ? (width  >> VAR_2->log2_chroma_w) : width;

        int h = (VAR_4 == 1 || VAR_4 == 2) ? (height >> VAR_2->log2_chroma_h) : height;

        uint8_t md5[16];



        av_md5_init(VAR_0->md5_ctx);

        for (VAR_5 = 0; VAR_5 < h; VAR_5++) {

            const uint8_t *src = VAR_1->data[VAR_4] + VAR_5 * VAR_1->linesize[VAR_4];

#if HAVE_BIGENDIAN

            if (VAR_3) {

                VAR_0->dsp.bswap16_buf((uint16_t*)VAR_0->checksum_buf,

                                   (const uint16_t*)src, w);

                src = VAR_0->checksum_buf;

            }

#endif

            av_md5_update(VAR_0->md5_ctx, src, w << VAR_3);

        }

        av_md5_final(VAR_0->md5_ctx, md5);



        if (!memcmp(md5, VAR_0->md5[VAR_4], 16)) {

            av_log   (VAR_0->avctx, AV_LOG_DEBUG, "plane %d - correct ", VAR_4);

            print_md5(VAR_0->avctx, AV_LOG_DEBUG, md5);

            av_log   (VAR_0->avctx, AV_LOG_DEBUG, "; ");

        } else {

            av_log   (VAR_0->avctx, AV_LOG_ERROR, "mismatching checksum of plane %d - ", VAR_4);

            print_md5(VAR_0->avctx, AV_LOG_ERROR, md5);

            av_log   (VAR_0->avctx, AV_LOG_ERROR, " != ");

            print_md5(VAR_0->avctx, AV_LOG_ERROR, VAR_0->md5[VAR_4]);

            av_log   (VAR_0->avctx, AV_LOG_ERROR, "\n");

            return AVERROR_INVALIDDATA;

        }

    }



    av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");



    return 0;

}

static int FUNC_0(HEVCContext *VAR_0, AVFrame *VAR_1)
{ const AVPixFmtDescriptor *VAR_2 = av_pix_fmt_desc_get(VAR_1->format); int VAR_3 = VAR_2->comp[0].depth_minus1 > 7; int VAR_4, VAR_5; if (!VAR_2)
return AVERROR(EINVAL); av_log(VAR_0->avctx, AV_LOG_DEBUG, "Verifying checksum for VAR_1 with POC %d: ",
VAR_0->poc); #if HAVE_BIGENDIAN
if (VAR_3 && !VAR_0->checksum_buf) { av_fast_malloc(&VAR_0->checksum_buf, &VAR_0->checksum_buf_size,
FFMAX3(VAR_1->linesize[0], VAR_1->linesize[1],
VAR_1->linesize[2])); if (!VAR_0->checksum_buf)
return AVERROR(ENOMEM); } #endif
for (VAR_4 = 0; VAR_1->data[VAR_4]; VAR_4++) { int width  = VAR_0->avctx->coded_width; int height = VAR_0->avctx->coded_height; int w = (VAR_4 == 1 || VAR_4 == 2) ? (width  >> VAR_2->log2_chroma_w) : width; int h = (VAR_4 == 1 || VAR_4 == 2) ? (height >> VAR_2->log2_chroma_h) : height; uint8_t md5[16]; av_md5_init(VAR_0->md5_ctx); for (VAR_5 = 0; VAR_5 < h; VAR_5++) { const uint8_t *src = VAR_1->data[VAR_4] + VAR_5 * VAR_1->linesize[VAR_4]; #if HAVE_BIGENDIAN
if (VAR_3) { VAR_0->dsp.bswap16_buf((uint16_t*)VAR_0->checksum_buf,
(const uint16_t*)src, w); src = VAR_0->checksum_buf; } #endif
av_md5_update(VAR_0->md5_ctx, src, w << VAR_3); } av_md5_final(VAR_0->md5_ctx, md5); if (!memcmp(md5, VAR_0->md5[VAR_4], 16)) { av_log   (VAR_0->avctx, AV_LOG_DEBUG, "plane %d - correct ", VAR_4); print_md5(VAR_0->avctx, AV_LOG_DEBUG, md5); av_log   (VAR_0->avctx, AV_LOG_DEBUG, "; "); } else { av_log   (VAR_0->avctx, AV_LOG_ERROR, "mismatching checksum of plane %d - ", VAR_4); print_md5(VAR_0->avctx, AV_LOG_ERROR, md5); av_log   (VAR_0->avctx, AV_LOG_ERROR, " != "); print_md5(VAR_0->avctx, AV_LOG_ERROR, VAR_0->md5[VAR_4]); av_log   (VAR_0->avctx, AV_LOG_ERROR, "\n"); return AVERROR_INVALIDDATA; } } av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n"); return 0; }