Lines Matching defs:avctx
52 static int vp9_alloc_entries(AVCodecContext *avctx, int n) {
53 VP9Context *s = avctx->priv_data;
56 if (avctx->active_thread_type & FF_THREAD_SLICE) {
87 static int vp9_alloc_entries(AVCodecContext *avctx, int n) { return 0; }
97 static void vp9_frame_unref(AVCodecContext *avctx, VP9Frame *f)
99 ff_thread_release_ext_buffer(avctx, &f->tf);
106 static int vp9_frame_alloc(AVCodecContext *avctx, VP9Frame *f)
108 VP9Context *s = avctx->priv_data;
111 ret = ff_thread_get_ext_buffer(avctx, &f->tf, AV_GET_BUFFER_FLAG_REF);
134 if (avctx->hwaccel) {
135 const AVHWAccel *hwaccel = avctx->hwaccel;
148 vp9_frame_unref(avctx, f);
152 static int vp9_frame_ref(AVCodecContext *avctx, VP9Frame *dst, VP9Frame *src)
178 vp9_frame_unref(avctx, dst);
182 static int update_size(AVCodecContext *avctx, int w, int h)
191 VP9Context *s = avctx->priv_data;
199 if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
241 ret = ff_thread_get_format(avctx, pix_fmts);
245 avctx->pix_fmt = ret;
262 lflvl_len = avctx->active_thread_type == FF_THREAD_SLICE ? s->sb_rows : 1;
297 ff_vp9dsp_init(&s->dsp, s->s.h.bpp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
305 static int update_block_buffers(AVCodecContext *avctx)
308 VP9Context *s = avctx->priv_data;
332 if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
353 if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
440 static int read_colorspace_details(AVCodecContext *avctx)
446 VP9Context *s = avctx->priv_data;
447 int bits = avctx->profile <= 1 ? 0 : 1 + get_bits1(&s->gb); // 0:8, 1:10, 2:12
452 avctx->colorspace = colorspaces[get_bits(&s->gb, 3)];
453 if (avctx->colorspace == AVCOL_SPC_RGB) { // RGB = profile 1
458 avctx->color_range = AVCOL_RANGE_JPEG;
460 if (avctx->profile & 1) {
462 av_log(avctx, AV_LOG_ERROR, "Reserved bit set in RGB\n");
466 av_log(avctx, AV_LOG_ERROR, "RGB not supported in profile %d\n",
467 avctx->profile);
479 avctx->color_range = get_bits1(&s->gb) ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
480 if (avctx->profile & 1) {
485 av_log(avctx, AV_LOG_ERROR, "YUV 4:2:0 not supported in profile %d\n",
486 avctx->profile);
489 av_log(avctx, AV_LOG_ERROR, "Profile %d color details reserved bit set\n",
490 avctx->profile);
502 static int decode_frame_header(AVCodecContext *avctx,
505 VP9Context *s = avctx->priv_data;
512 av_log(avctx, AV_LOG_ERROR, "Failed to initialize bitstream reader\n");
516 av_log(avctx, AV_LOG_ERROR, "Invalid frame marker\n");
519 avctx->profile = get_bits1(&s->gb);
520 avctx->profile |= get_bits1(&s->gb) << 1;
521 if (avctx->profile == 3) avctx->profile += get_bits1(&s->gb);
522 if (avctx->profile > 3) {
523 av_log(avctx, AV_LOG_ERROR, "Profile %d is not yet supported\n", avctx->profile);
526 s->s.h.profile = avctx->profile;
542 av_log(avctx, AV_LOG_ERROR, "Invalid sync code\n");
545 if ((ret = read_colorspace_details(avctx)) < 0)
558 av_log(avctx, AV_LOG_ERROR, "Invalid sync code\n");
561 if (avctx->profile >= 1) {
562 if ((ret = read_colorspace_details(avctx)) < 0)
570 avctx->colorspace = AVCOL_SPC_BT470BG;
571 avctx->color_range = AVCOL_RANGE_MPEG;
589 av_log(avctx, AV_LOG_ERROR, "Not all references are available\n");
689 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
767 if ((ret = update_size(avctx, w, h)) < 0) {
768 av_log(avctx, AV_LOG_ERROR, "Failed to initialize decoder for %dx%d @ %d\n",
796 s->active_tile_cols = avctx->active_thread_type == FF_THREAD_SLICE ?
798 vp9_alloc_entries(avctx, s->sb_rows);
799 if (avctx->active_thread_type == FF_THREAD_SLICE) {
823 if (ref->format != avctx->pix_fmt) {
824 av_log(avctx, AV_LOG_ERROR,
827 av_get_pix_fmt_name(avctx->pix_fmt));
835 av_log(avctx, AV_LOG_WARNING,
849 av_log(avctx, AV_LOG_ERROR, "No valid reference frame is found, bitstream not supported\n");
877 av_log(avctx, AV_LOG_ERROR, "Invalid compressed header size\n");
885 av_log(avctx, AV_LOG_ERROR, "Marker bit was set\n");
1232 static av_cold int vp9_decode_free(AVCodecContext *avctx)
1234 VP9Context *s = avctx->priv_data;
1238 vp9_frame_unref(avctx, &s->s.frames[i]);
1243 ff_thread_release_ext_buffer(avctx, &s->s.refs[i]);
1245 ff_thread_release_ext_buffer(avctx, &s->next_refs[i]);
1258 static int decode_tiles(AVCodecContext *avctx,
1261 VP9Context *s = avctx->priv_data;
1377 ff_vp9_loopfilter_sb(avctx, lflvl_ptr, row, col,
1393 int decode_tiles_mt(AVCodecContext *avctx, void *tdata, int jobnr,
1396 VP9Context *s = avctx->priv_data;
1470 int loopfilter_proc(AVCodecContext *avctx)
1472 VP9Context *s = avctx->priv_data;
1492 ff_vp9_loopfilter_sb(avctx, lflvl_ptr, i << 3, col,
1553 static int vp9_decode_frame(AVCodecContext *avctx, AVFrame *frame,
1558 VP9Context *s = avctx->priv_data;
1564 if ((ret = decode_frame_header(avctx, data, size, &ref)) < 0) {
1568 av_log(avctx, AV_LOG_ERROR, "Requested reference %d not available\n", ref);
1577 ff_thread_release_ext_buffer(avctx, &s->next_refs[i]);
1590 vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_SEGMAP]);
1592 (ret = vp9_frame_ref(avctx, &s->s.frames[REF_FRAME_SEGMAP], &s->s.frames[CUR_FRAME])) < 0)
1596 vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_MVPAIR]);
1598 (ret = vp9_frame_ref(avctx, &s->s.frames[REF_FRAME_MVPAIR], &s->s.frames[CUR_FRAME])) < 0)
1601 vp9_frame_unref(avctx, &s->s.frames[CUR_FRAME]);
1602 if ((ret = vp9_frame_alloc(avctx, &s->s.frames[CUR_FRAME])) < 0)
1611 vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_SEGMAP]);
1617 ff_thread_release_ext_buffer(avctx, &s->next_refs[i]);
1627 if (avctx->hwaccel) {
1628 ret = avctx->hwaccel->start_frame(avctx, NULL, 0);
1631 ret = avctx->hwaccel->decode_slice(avctx, pkt->data, pkt->size);
1634 ret = avctx->hwaccel->end_frame(avctx);
1653 avctx->active_thread_type == FF_THREAD_FRAME && s->s.h.refreshctx && !s->s.h.parallelmode;
1654 if ((ret = update_block_buffers(avctx)) < 0) {
1655 av_log(avctx, AV_LOG_ERROR,
1673 ff_thread_finish_setup(avctx);
1675 ff_thread_finish_setup(avctx);
1679 if (avctx->active_thread_type & FF_THREAD_SLICE) {
1698 if (avctx->active_thread_type == FF_THREAD_SLICE) {
1727 ff_slice_thread_execute_with_mainfunc(avctx, decode_tiles_mt, loopfilter_proc, s->td, NULL, s->s.h.tiling.tile_cols);
1731 ret = decode_tiles(avctx, data, size);
1739 if (avctx->active_thread_type == FF_THREAD_SLICE)
1746 ff_thread_finish_setup(avctx);
1752 av_log(avctx, AV_LOG_ERROR, "Failed to decode tile data\n");
1756 if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
1766 ff_thread_release_ext_buffer(avctx, &s->s.refs[i]);
1781 static void vp9_decode_flush(AVCodecContext *avctx)
1783 VP9Context *s = avctx->priv_data;
1787 vp9_frame_unref(avctx, &s->s.frames[i]);
1789 ff_thread_release_ext_buffer(avctx, &s->s.refs[i]);
1792 static av_cold int vp9_decode_init(AVCodecContext *avctx)
1794 VP9Context *s = avctx->priv_data;
1801 if (avctx->active_thread_type & FF_THREAD_SLICE) {