libavcodec/hevc.c:515: error: Buffer Overrun L1
  Offset: -1 Size: 7 by call to `set_sps`.

libavcodec/hevc.c:514:9: Call
512.         s->sps = (HEVCSPS*)s->sps_list[s->pps->sps_id]->data;
513. 
514.         ff_hevc_clear_refs(s);
             ^
515.         ret = set_sps(s, s->sps);
516.         if (ret < 0)

libavcodec/hevc_refs.c:70:9: Call
  68.     int i;
  69.     for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++)
  70.         ff_hevc_unref_frame(s, &s->DPB[i],
              ^
  71.                             HEVC_FRAME_FLAG_SHORT_REF |
  72.                             HEVC_FRAME_FLAG_LONG_REF);

libavcodec/hevc_refs.c:39:9: Call
    37.     frame->flags &= ~flags;
    38.     if (!frame->flags) {
    39.         ff_thread_release_buffer(s->avctx, &frame->tf);
                ^
    40. 
    41.         av_buffer_unref(&frame->tab_mvf_buf);

libavcodec/pthread_frame.c:778:9: Call
      776. 
      777.     if (can_direct_free) {
      778.         av_frame_unref(f->f);
                   ^
      779.         return;
      780.     }

libavutil/frame.c:306:5: Call
        304.         av_buffer_unref(&frame->extended_buf[i]);
        305.     av_freep(&frame->extended_buf);
        306.     get_frame_defaults(frame);
                 ^
        307. }
        308. 

libavutil/frame.c:38:46: Assignment
          36.     frame->pts                 = AV_NOPTS_VALUE;
          37.     frame->key_frame           = 1;
          38.     frame->sample_aspect_ratio = (AVRational){ 0, 1 };
                                                           ^
          39.     frame->format              = -1; /* unknown */
          40.     frame->extended_data       = frame->data;

libavcodec/hevc.c:515:15: Call
513. 
514.         ff_hevc_clear_refs(s);
515.         ret = set_sps(s, s->sps);
                   ^
516.         if (ret < 0)
517.             return ret;

libavcodec/hevc.c:432:1: Parameter `sps->max_sub_layers`
  430. }
  431. 
  432. static int set_sps(HEVCContext *s, const HEVCSPS *sps)
       ^
  433. {
  434.     #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL)

libavcodec/hevc.c:438:5: Call
  436.     int ret;
  437. 
  438.     export_stream_params(s->avctx, s, sps);
           ^
  439. 
  440.     pic_arrays_free(s);

libavcodec/hevc.c:386:1: <Offset trace>
384. }
385. 
386. static void export_stream_params(AVCodecContext *avctx,
     ^
387.                                  const HEVCContext *s, const HEVCSPS *sps)
388. {

libavcodec/hevc.c:386:1: Parameter `sps->max_sub_layers`
    384. }
    385. 
    386. static void export_stream_params(AVCodecContext *avctx,
         ^
    387.                                  const HEVCContext *s, const HEVCSPS *sps)
    388. {

libavcodec/hevc.c:386:1: <Length trace>
384. }
385. 
386. static void export_stream_params(AVCodecContext *avctx,
     ^
387.                                  const HEVCContext *s, const HEVCSPS *sps)
388. {

libavcodec/hevc.c:386:1: Parameter `sps->temporal_layer[*]`
    384. }
    385. 
    386. static void export_stream_params(AVCodecContext *avctx,
         ^
    387.                                  const HEVCContext *s, const HEVCSPS *sps)
    388. {

libavcodec/hevc.c:397:34: Array access: Offset: -1 Size: 7 by call to `set_sps` 
    395.     avctx->width               = sps->output_width;
    396.     avctx->height              = sps->output_height;
    397.     avctx->has_b_frames        = sps->temporal_layer[sps->max_sub_layers - 1].num_reorder_pics;
                                          ^
    398.     avctx->profile             = sps->ptl.general_ptl.profile_idc;
    399.     avctx->level               = sps->ptl.general_ptl.level_idc;

static void export_stream_params(AVCodecContext *avctx,
                                 const HEVCContext *s, const HEVCSPS *sps)
{
    const HEVCVPS *vps = (const HEVCVPS*)s->vps_list[sps->vps_id]->data;
    unsigned int num = 0, den = 0;
    avctx->pix_fmt             = sps->pix_fmt;
    avctx->coded_width         = sps->width;
    avctx->coded_height        = sps->height;
    avctx->width               = sps->output_width;
    avctx->height              = sps->output_height;
    avctx->has_b_frames        = sps->temporal_layer[sps->max_sub_layers - 1].num_reorder_pics;
    avctx->profile             = sps->ptl.general_ptl.profile_idc;
    avctx->level               = sps->ptl.general_ptl.level_idc;
    ff_set_sar(avctx, sps->vui.sar);
    if (sps->vui.video_signal_type_present_flag)
        avctx->color_range = sps->vui.video_full_range_flag ? AVCOL_RANGE_JPEG
                                                            : AVCOL_RANGE_MPEG;
    else
        avctx->color_range = AVCOL_RANGE_MPEG;
    if (sps->vui.colour_description_present_flag) {
        avctx->color_primaries = sps->vui.colour_primaries;
        avctx->color_trc       = sps->vui.transfer_characteristic;
        avctx->colorspace      = sps->vui.matrix_coeffs;
    } else {
        avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
        avctx->color_trc       = AVCOL_TRC_UNSPECIFIED;
        avctx->colorspace      = AVCOL_SPC_UNSPECIFIED;
    }
    if (vps->vps_timing_info_present_flag) {
        num = vps->vps_num_units_in_tick;
        den = vps->vps_time_scale;
    } else if (sps->vui.vui_timing_info_present_flag) {
        num = sps->vui.vui_num_units_in_tick;
        den = sps->vui.vui_time_scale;
    }
    if (num != 0 && den != 0)
        av_reduce(&avctx->framerate.den, &avctx->framerate.num,
                  num, den, 1 << 30);
}
['static int hls_slice_header(HEVCContext *s)\n{\n    GetBitContext *gb = &s->HEVClc.gb;\n    SliceHeader *sh   = &s->sh;\n    int i, ret;\n    sh->first_slice_in_pic_flag = get_bits1(gb);\n    if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {\n        s->seq_decode = (s->seq_decode + 1) & 0xff;\n        s->max_ra     = INT_MAX;\n        if (IS_IDR(s))\n            ff_hevc_clear_refs(s);\n    }\n    if (IS_IRAP(s))\n        sh->no_output_of_prior_pics_flag = get_bits1(gb);\n    sh->pps_id = get_ue_golomb_long(gb);\n    if (sh->pps_id >= MAX_PPS_COUNT || !s->pps_list[sh->pps_id]) {\n        av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\\n", sh->pps_id);\n        return AVERROR_INVALIDDATA;\n    }\n    if (!sh->first_slice_in_pic_flag &&\n        s->pps != (HEVCPPS*)s->pps_list[sh->pps_id]->data) {\n        av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    s->pps = (HEVCPPS*)s->pps_list[sh->pps_id]->data;\n    if (s->sps != (HEVCSPS*)s->sps_list[s->pps->sps_id]->data) {\n        s->sps = (HEVCSPS*)s->sps_list[s->pps->sps_id]->data;\n        ff_hevc_clear_refs(s);\n        ret = set_sps(s, s->sps);\n        if (ret < 0)\n            return ret;\n        s->seq_decode = (s->seq_decode + 1) & 0xff;\n        s->max_ra     = INT_MAX;\n    }\n    sh->dependent_slice_segment_flag = 0;\n    if (!sh->first_slice_in_pic_flag) {\n        int slice_address_length;\n        if (s->pps->dependent_slice_segments_enabled_flag)\n            sh->dependent_slice_segment_flag = get_bits1(gb);\n        slice_address_length = av_ceil_log2(s->sps->ctb_width *\n                                            s->sps->ctb_height);\n        sh->slice_segment_addr = get_bits(gb, slice_address_length);\n        if (sh->slice_segment_addr >= s->sps->ctb_width * s->sps->ctb_height) {\n            av_log(s->avctx, AV_LOG_ERROR,\n                   "Invalid slice segment address: %u.\\n",\n                   sh->slice_segment_addr);\n            return AVERROR_INVALIDDATA;\n        }\n        if (!sh->dependent_slice_segment_flag) {\n            sh->slice_addr = sh->slice_segment_addr;\n            s->slice_idx++;\n        }\n    } else {\n        sh->slice_segment_addr = sh->slice_addr = 0;\n        s->slice_idx           = 0;\n        s->slice_initialized   = 0;\n    }\n    if (!sh->dependent_slice_segment_flag) {\n        s->slice_initialized = 0;\n        for (i = 0; i < s->pps->num_extra_slice_header_bits; i++)\n            skip_bits(gb, 1);\n        sh->slice_type = get_ue_golomb_long(gb);\n        if (!(sh->slice_type == I_SLICE ||\n              sh->slice_type == P_SLICE ||\n              sh->slice_type == B_SLICE)) {\n            av_log(s->avctx, AV_LOG_ERROR, "Unknown slice type: %d.\\n",\n                   sh->slice_type);\n            return AVERROR_INVALIDDATA;\n        }\n        if (IS_IRAP(s) && sh->slice_type != I_SLICE) {\n            av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\\n");\n            return AVERROR_INVALIDDATA;\n        }\n        sh->pic_output_flag = 1;\n        if (s->pps->output_flag_present_flag)\n            sh->pic_output_flag = get_bits1(gb);\n        if (s->sps->separate_colour_plane_flag)\n            sh->colour_plane_id = get_bits(gb, 2);\n        if (!IS_IDR(s)) {\n            int poc;\n            sh->pic_order_cnt_lsb = get_bits(gb, s->sps->log2_max_poc_lsb);\n            poc = ff_hevc_compute_poc(s, sh->pic_order_cnt_lsb);\n            if (!sh->first_slice_in_pic_flag && poc != s->poc) {\n                av_log(s->avctx, AV_LOG_WARNING,\n                       "Ignoring POC change between slices: %d -> %d\\n", s->poc, poc);\n                if (s->avctx->err_recognition & AV_EF_EXPLODE)\n                    return AVERROR_INVALIDDATA;\n                poc = s->poc;\n            }\n            s->poc = poc;\n            sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);\n            if (!sh->short_term_ref_pic_set_sps_flag) {\n                int pos = get_bits_left(gb);\n                ret = ff_hevc_decode_short_term_rps(s, &sh->slice_rps, s->sps, 1);\n                if (ret < 0)\n                    return ret;\n                sh->short_term_ref_pic_set_size = pos - get_bits_left(gb);\n                sh->short_term_rps = &sh->slice_rps;\n            } else {\n                int numbits, rps_idx;\n                if (!s->sps->nb_st_rps) {\n                    av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\\n");\n                    return AVERROR_INVALIDDATA;\n                }\n                numbits = av_ceil_log2(s->sps->nb_st_rps);\n                rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0;\n                sh->short_term_rps = &s->sps->st_rps[rps_idx];\n            }\n            ret = decode_lt_rps(s, &sh->long_term_rps, gb);\n            if (ret < 0) {\n                av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\\n");\n                if (s->avctx->err_recognition & AV_EF_EXPLODE)\n                    return AVERROR_INVALIDDATA;\n            }\n            if (s->sps->sps_temporal_mvp_enabled_flag)\n                sh->slice_temporal_mvp_enabled_flag = get_bits1(gb);\n            else\n                sh->slice_temporal_mvp_enabled_flag = 0;\n        } else {\n            s->sh.short_term_rps = NULL;\n            s->poc               = 0;\n        }\n        if (s->temporal_id == 0 &&\n            s->nal_unit_type != NAL_TRAIL_N &&\n            s->nal_unit_type != NAL_TSA_N   &&\n            s->nal_unit_type != NAL_STSA_N  &&\n            s->nal_unit_type != NAL_RADL_N  &&\n            s->nal_unit_type != NAL_RADL_R  &&\n            s->nal_unit_type != NAL_RASL_N  &&\n            s->nal_unit_type != NAL_RASL_R)\n            s->pocTid0 = s->poc;\n        if (s->sps->sao_enabled) {\n            sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);\n            sh->slice_sample_adaptive_offset_flag[1] =\n            sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);\n        } else {\n            sh->slice_sample_adaptive_offset_flag[0] = 0;\n            sh->slice_sample_adaptive_offset_flag[1] = 0;\n            sh->slice_sample_adaptive_offset_flag[2] = 0;\n        }\n        sh->nb_refs[L0] = sh->nb_refs[L1] = 0;\n        if (sh->slice_type == P_SLICE || sh->slice_type == B_SLICE) {\n            int nb_refs;\n            sh->nb_refs[L0] = s->pps->num_ref_idx_l0_default_active;\n            if (sh->slice_type == B_SLICE)\n                sh->nb_refs[L1] = s->pps->num_ref_idx_l1_default_active;\n            if (get_bits1(gb)) {\n                sh->nb_refs[L0] = get_ue_golomb_long(gb) + 1;\n                if (sh->slice_type == B_SLICE)\n                    sh->nb_refs[L1] = get_ue_golomb_long(gb) + 1;\n            }\n            if (sh->nb_refs[L0] > MAX_REFS || sh->nb_refs[L1] > MAX_REFS) {\n                av_log(s->avctx, AV_LOG_ERROR, "Too many refs: %d/%d.\\n",\n                       sh->nb_refs[L0], sh->nb_refs[L1]);\n                return AVERROR_INVALIDDATA;\n            }\n            sh->rpl_modification_flag[0] = 0;\n            sh->rpl_modification_flag[1] = 0;\n            nb_refs = ff_hevc_frame_nb_refs(s);\n            if (!nb_refs) {\n                av_log(s->avctx, AV_LOG_ERROR, "Zero refs for a frame with P or B slices.\\n");\n                return AVERROR_INVALIDDATA;\n            }\n            if (s->pps->lists_modification_present_flag && nb_refs > 1) {\n                sh->rpl_modification_flag[0] = get_bits1(gb);\n                if (sh->rpl_modification_flag[0]) {\n                    for (i = 0; i < sh->nb_refs[L0]; i++)\n                        sh->list_entry_lx[0][i] = get_bits(gb, av_ceil_log2(nb_refs));\n                }\n                if (sh->slice_type == B_SLICE) {\n                    sh->rpl_modification_flag[1] = get_bits1(gb);\n                    if (sh->rpl_modification_flag[1] == 1)\n                        for (i = 0; i < sh->nb_refs[L1]; i++)\n                            sh->list_entry_lx[1][i] = get_bits(gb, av_ceil_log2(nb_refs));\n                }\n            }\n            if (sh->slice_type == B_SLICE)\n                sh->mvd_l1_zero_flag = get_bits1(gb);\n            if (s->pps->cabac_init_present_flag)\n                sh->cabac_init_flag = get_bits1(gb);\n            else\n                sh->cabac_init_flag = 0;\n            sh->collocated_ref_idx = 0;\n            if (sh->slice_temporal_mvp_enabled_flag) {\n                sh->collocated_list = L0;\n                if (sh->slice_type == B_SLICE)\n                    sh->collocated_list = !get_bits1(gb);\n                if (sh->nb_refs[sh->collocated_list] > 1) {\n                    sh->collocated_ref_idx = get_ue_golomb_long(gb);\n                    if (sh->collocated_ref_idx >= sh->nb_refs[sh->collocated_list]) {\n                        av_log(s->avctx, AV_LOG_ERROR,\n                               "Invalid collocated_ref_idx: %d.\\n",\n                               sh->collocated_ref_idx);\n                        return AVERROR_INVALIDDATA;\n                    }\n                }\n            }\n            if ((s->pps->weighted_pred_flag   && sh->slice_type == P_SLICE) ||\n                (s->pps->weighted_bipred_flag && sh->slice_type == B_SLICE)) {\n                pred_weight_table(s, gb);\n            }\n            sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);\n            if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {\n                av_log(s->avctx, AV_LOG_ERROR,\n                       "Invalid number of merging MVP candidates: %d.\\n",\n                       sh->max_num_merge_cand);\n                return AVERROR_INVALIDDATA;\n            }\n        }\n        sh->slice_qp_delta = get_se_golomb(gb);\n        if (s->pps->pic_slice_level_chroma_qp_offsets_present_flag) {\n            sh->slice_cb_qp_offset = get_se_golomb(gb);\n            sh->slice_cr_qp_offset = get_se_golomb(gb);\n        } else {\n            sh->slice_cb_qp_offset = 0;\n            sh->slice_cr_qp_offset = 0;\n        }\n        if (s->pps->deblocking_filter_control_present_flag) {\n            int deblocking_filter_override_flag = 0;\n            if (s->pps->deblocking_filter_override_enabled_flag)\n                deblocking_filter_override_flag = get_bits1(gb);\n            if (deblocking_filter_override_flag) {\n                sh->disable_deblocking_filter_flag = get_bits1(gb);\n                if (!sh->disable_deblocking_filter_flag) {\n                    sh->beta_offset = get_se_golomb(gb) * 2;\n                    sh->tc_offset   = get_se_golomb(gb) * 2;\n                }\n            } else {\n                sh->disable_deblocking_filter_flag = s->pps->disable_dbf;\n                sh->beta_offset                    = s->pps->beta_offset;\n                sh->tc_offset                      = s->pps->tc_offset;\n            }\n        } else {\n            sh->disable_deblocking_filter_flag = 0;\n            sh->beta_offset                    = 0;\n            sh->tc_offset                      = 0;\n        }\n        if (s->pps->seq_loop_filter_across_slices_enabled_flag &&\n            (sh->slice_sample_adaptive_offset_flag[0] ||\n             sh->slice_sample_adaptive_offset_flag[1] ||\n             !sh->disable_deblocking_filter_flag)) {\n            sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);\n        } else {\n            sh->slice_loop_filter_across_slices_enabled_flag = s->pps->seq_loop_filter_across_slices_enabled_flag;\n        }\n    } else if (!s->slice_initialized) {\n        av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    sh->num_entry_point_offsets = 0;\n    if (s->pps->tiles_enabled_flag || s->pps->entropy_coding_sync_enabled_flag) {\n        sh->num_entry_point_offsets = get_ue_golomb_long(gb);\n        if (sh->num_entry_point_offsets > 0) {\n            int offset_len = get_ue_golomb_long(gb) + 1;\n            for (i = 0; i < sh->num_entry_point_offsets; i++)\n                skip_bits(gb, offset_len);\n        }\n    }\n    if (s->pps->slice_header_extension_present_flag) {\n        unsigned int length = get_ue_golomb_long(gb);\n        for (i = 0; i < length; i++)\n            skip_bits(gb, 8);\n    }\n    sh->slice_qp = 26 + s->pps->pic_init_qp_minus26 + sh->slice_qp_delta;\n    if (sh->slice_qp > 51 ||\n        sh->slice_qp < -s->sps->qp_bd_offset) {\n        av_log(s->avctx, AV_LOG_ERROR,\n               "The slice_qp %d is outside the valid range "\n               "[%d, 51].\\n",\n               sh->slice_qp,\n               -s->sps->qp_bd_offset);\n        return AVERROR_INVALIDDATA;\n    }\n    sh->slice_ctb_addr_rs = sh->slice_segment_addr;\n    if (!s->sh.slice_ctb_addr_rs && s->sh.dependent_slice_segment_flag) {\n        av_log(s->avctx, AV_LOG_ERROR, "Impossible slice segment.\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    s->HEVClc.first_qp_group = !s->sh.dependent_slice_segment_flag;\n    if (!s->pps->cu_qp_delta_enabled_flag)\n        s->HEVClc.qp_y = FFUMOD(s->sh.slice_qp + 52 + 2 * s->sps->qp_bd_offset,\n                                52 + s->sps->qp_bd_offset) - s->sps->qp_bd_offset;\n    s->slice_initialized = 1;\n    return 0;\n}', 'void ff_hevc_clear_refs(HEVCContext *s)\n{\n    int i;\n    for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++)\n        ff_hevc_unref_frame(s, &s->DPB[i],\n                            HEVC_FRAME_FLAG_SHORT_REF |\n                            HEVC_FRAME_FLAG_LONG_REF);\n}', 'void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)\n{\n    if (!frame->frame || !frame->frame->buf[0])\n        return;\n    frame->flags &= ~flags;\n    if (!frame->flags) {\n        ff_thread_release_buffer(s->avctx, &frame->tf);\n        av_buffer_unref(&frame->tab_mvf_buf);\n        frame->tab_mvf = NULL;\n        av_buffer_unref(&frame->rpl_buf);\n        av_buffer_unref(&frame->rpl_tab_buf);\n        frame->rpl_tab    = NULL;\n        frame->refPicList = NULL;\n        frame->collocated_ref = NULL;\n        av_buffer_unref(&frame->hwaccel_priv_buf);\n        frame->hwaccel_picture_private = NULL;\n    }\n}', 'void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)\n{\n    PerThreadContext *p = avctx->internal->thread_ctx;\n    FrameThreadContext *fctx;\n    AVFrame *dst, *tmp;\nFF_DISABLE_DEPRECATION_WARNINGS\n    int can_direct_free = !(avctx->active_thread_type & FF_THREAD_FRAME) ||\n                          avctx->thread_safe_callbacks                   ||\n                          (\n#if FF_API_GET_BUFFER\n                           !avctx->get_buffer &&\n#endif\n                           avctx->get_buffer2 == avcodec_default_get_buffer2);\nFF_ENABLE_DEPRECATION_WARNINGS\n    if (!f->f || !f->f->buf[0])\n        return;\n    if (avctx->debug & FF_DEBUG_BUFFERS)\n        av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p\\n", f);\n    av_buffer_unref(&f->progress);\n    f->owner    = NULL;\n    if (can_direct_free) {\n        av_frame_unref(f->f);\n        return;\n    }\n    fctx = p->parent;\n    pthread_mutex_lock(&fctx->buffer_mutex);\n    if (p->num_released_buffers + 1 >= INT_MAX / sizeof(*p->released_buffers))\n        goto fail;\n    tmp = av_fast_realloc(p->released_buffers, &p->released_buffers_allocated,\n                          (p->num_released_buffers + 1) *\n                          sizeof(*p->released_buffers));\n    if (!tmp)\n        goto fail;\n    p->released_buffers = tmp;\n    dst = &p->released_buffers[p->num_released_buffers];\n    av_frame_move_ref(dst, f->f);\n    p->num_released_buffers++;\nfail:\n    pthread_mutex_unlock(&fctx->buffer_mutex);\n}', 'void av_frame_unref(AVFrame *frame)\n{\n    int i;\n    wipe_side_data(frame);\n    for (i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++)\n        av_buffer_unref(&frame->buf[i]);\n    for (i = 0; i < frame->nb_extended_buf; i++)\n        av_buffer_unref(&frame->extended_buf[i]);\n    av_freep(&frame->extended_buf);\n    get_frame_defaults(frame);\n}', 'static void get_frame_defaults(AVFrame *frame)\n{\n    if (frame->extended_data != frame->data)\n        av_freep(&frame->extended_data);\n    memset(frame, 0, sizeof(*frame));\n    frame->pts                 = AV_NOPTS_VALUE;\n    frame->key_frame           = 1;\n    frame->sample_aspect_ratio = (AVRational){ 0, 1 };\n    frame->format              = -1;\n    frame->extended_data       = frame->data;\n    frame->color_primaries     = AVCOL_PRI_UNSPECIFIED;\n    frame->color_trc           = AVCOL_TRC_UNSPECIFIED;\n    frame->colorspace          = AVCOL_SPC_UNSPECIFIED;\n    frame->color_range         = AVCOL_RANGE_UNSPECIFIED;\n    frame->chroma_location     = AVCHROMA_LOC_UNSPECIFIED;\n}', 'static int set_sps(HEVCContext *s, const HEVCSPS *sps)\n{\n    #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL)\n    enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;\n    int ret;\n    export_stream_params(s->avctx, s, sps);\n    pic_arrays_free(s);\n    ret = pic_arrays_init(s, sps);\n    if (ret < 0)\n        goto fail;\n    if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P) {\n#if CONFIG_HEVC_DXVA2_HWACCEL\n        *fmt++ = AV_PIX_FMT_DXVA2_VLD;\n#endif\n    }\n    *fmt++ = sps->pix_fmt;\n    *fmt = AV_PIX_FMT_NONE;\n    ret = ff_get_format(s->avctx, pix_fmts);\n    if (ret < 0)\n        goto fail;\n    s->avctx->pix_fmt = ret;\n    ff_hevc_pred_init(&s->hpc,     sps->bit_depth);\n    ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth);\n    ff_videodsp_init (&s->vdsp,    sps->bit_depth);\n    if (sps->sao_enabled && !s->avctx->hwaccel) {\n        av_frame_unref(s->tmp_frame);\n        ret = ff_get_buffer(s->avctx, s->tmp_frame, AV_GET_BUFFER_FLAG_REF);\n        if (ret < 0)\n            goto fail;\n        s->frame = s->tmp_frame;\n    }\n    s->sps = sps;\n    s->vps = (HEVCVPS*) s->vps_list[s->sps->vps_id]->data;\n    return 0;\nfail:\n    pic_arrays_free(s);\n    s->sps = NULL;\n    return ret;\n}', 'static void export_stream_params(AVCodecContext *avctx,\n                                 const HEVCContext *s, const HEVCSPS *sps)\n{\n    const HEVCVPS *vps = (const HEVCVPS*)s->vps_list[sps->vps_id]->data;\n    unsigned int num = 0, den = 0;\n    avctx->pix_fmt             = sps->pix_fmt;\n    avctx->coded_width         = sps->width;\n    avctx->coded_height        = sps->height;\n    avctx->width               = sps->output_width;\n    avctx->height              = sps->output_height;\n    avctx->has_b_frames        = sps->temporal_layer[sps->max_sub_layers - 1].num_reorder_pics;\n    avctx->profile             = sps->ptl.general_ptl.profile_idc;\n    avctx->level               = sps->ptl.general_ptl.level_idc;\n    ff_set_sar(avctx, sps->vui.sar);\n    if (sps->vui.video_signal_type_present_flag)\n        avctx->color_range = sps->vui.video_full_range_flag ? AVCOL_RANGE_JPEG\n                                                            : AVCOL_RANGE_MPEG;\n    else\n        avctx->color_range = AVCOL_RANGE_MPEG;\n    if (sps->vui.colour_description_present_flag) {\n        avctx->color_primaries = sps->vui.colour_primaries;\n        avctx->color_trc       = sps->vui.transfer_characteristic;\n        avctx->colorspace      = sps->vui.matrix_coeffs;\n    } else {\n        avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;\n        avctx->color_trc       = AVCOL_TRC_UNSPECIFIED;\n        avctx->colorspace      = AVCOL_SPC_UNSPECIFIED;\n    }\n    if (vps->vps_timing_info_present_flag) {\n        num = vps->vps_num_units_in_tick;\n        den = vps->vps_time_scale;\n    } else if (sps->vui.vui_timing_info_present_flag) {\n        num = sps->vui.vui_num_units_in_tick;\n        den = sps->vui.vui_time_scale;\n    }\n    if (num != 0 && den != 0)\n        av_reduce(&avctx->framerate.den, &avctx->framerate.num,\n                  num, den, 1 << 30);\n}']