Lines Matching defs:avctx
389 static int get_tiles_info(AVCodecContext *avctx, const AV1RawTileGroup *tile_group)
391 AV1DecContext *s = avctx->priv_data;
434 static int get_pixel_format(AVCodecContext *avctx)
436 AV1DecContext *s = avctx->priv_data;
453 av_log(avctx, AV_LOG_ERROR,
469 av_log(avctx, AV_LOG_WARNING, "Unknown AV1 pixel format.\n");
479 av_log(avctx, AV_LOG_WARNING, "Unknown AV1 pixel format.\n");
489 av_log(avctx, AV_LOG_WARNING, "Unknown AV1 pixel format.\n");
499 av_log(avctx, AV_LOG_WARNING, "Unknown AV1 pixel format.\n");
502 av_log(avctx, AV_LOG_DEBUG, "AV1 decode get format: %s.\n",
560 ret = ff_thread_get_format(avctx, pix_fmts);
569 if (!avctx->hwaccel) {
570 av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport"
576 avctx->pix_fmt = ret;
581 static void av1_frame_unref(AVCodecContext *avctx, AV1Frame *f)
583 ff_thread_release_buffer(avctx, f->f);
595 static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src)
641 av1_frame_unref(avctx, dst);
645 static av_cold int av1_decode_free(AVCodecContext *avctx)
647 AV1DecContext *s = avctx->priv_data;
650 av1_frame_unref(avctx, &s->ref[i]);
653 av1_frame_unref(avctx, &s->cur_frame);
666 static int set_context_with_sequence(AVCodecContext *avctx,
672 avctx->profile = seq->seq_profile;
673 avctx->level = seq->seq_level_idx[0];
675 avctx->color_range =
677 avctx->color_primaries = seq->color_config.color_primaries;
678 avctx->colorspace = seq->color_config.color_primaries;
679 avctx->color_trc = seq->color_config.transfer_characteristics;
683 avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
686 avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
691 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
693 avctx->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN;
695 if (avctx->width != width || avctx->height != height) {
696 int ret = ff_set_dimensions(avctx, width, height);
700 avctx->sample_aspect_ratio = (AVRational) { 1, 1 };
704 av_reduce(&avctx->framerate.den, &avctx->framerate.num,
709 avctx->ticks_per_frame = seq->timing_info.num_ticks_per_picture_minus_1 + 1;
715 static int update_context_with_frame_header(AVCodecContext *avctx,
725 if (avctx->width != width || avctx->height != height) {
726 ret = ff_set_dimensions(avctx, width, height);
736 if (av_cmp_q(avctx->sample_aspect_ratio, aspect_ratio)) {
737 ret = ff_set_sar(avctx, aspect_ratio);
745 static av_cold int av1_decode_init(AVCodecContext *avctx)
747 AV1DecContext *s = avctx->priv_data;
751 s->avctx = avctx;
757 av_log(avctx, AV_LOG_ERROR,
765 av_log(avctx, AV_LOG_ERROR,
770 ret = ff_cbs_init(&s->cbc, AV_CODEC_ID_AV1, avctx);
776 if (avctx->extradata && avctx->extradata_size) {
779 avctx);
781 av_log(avctx, AV_LOG_WARNING, "Failed to read extradata.\n");
787 av_log(avctx, AV_LOG_WARNING, "No sequence header available.\n");
791 ret = set_context_with_sequence(avctx, seq);
793 av_log(avctx, AV_LOG_WARNING, "Failed to set decoder context.\n");
804 static int av1_frame_alloc(AVCodecContext *avctx, AV1Frame *f)
806 AV1DecContext *s = avctx->priv_data;
811 ret = update_context_with_frame_header(avctx, header);
813 av_log(avctx, AV_LOG_ERROR, "Failed to update context with frame header\n");
817 if ((ret = ff_thread_get_buffer(avctx, f->f, AV_GET_BUFFER_FLAG_REF)) < 0)
836 if (avctx->hwaccel) {
837 const AVHWAccel *hwaccel = avctx->hwaccel;
851 av1_frame_unref(avctx, f);
855 static int export_film_grain(AVCodecContext *avctx, AVFrame *frame)
857 AV1DecContext *s = avctx->priv_data;
915 static int set_output_frame(AVCodecContext *avctx, AVFrame *frame,
918 AV1DecContext *s = avctx->priv_data;
931 if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) {
932 ret = export_film_grain(avctx, frame);
948 static int update_reference_list(AVCodecContext *avctx)
950 AV1DecContext *s = avctx->priv_data;
956 av1_frame_unref(avctx, &s->ref[i]);
957 if ((ret = av1_frame_ref(avctx, &s->ref[i], &s->cur_frame)) < 0) {
958 av_log(avctx, AV_LOG_ERROR,
967 static int get_current_frame(AVCodecContext *avctx)
969 AV1DecContext *s = avctx->priv_data;
972 av1_frame_unref(avctx, &s->cur_frame);
982 av_log(avctx, AV_LOG_ERROR, "Failed to init tile data.\n");
986 if ((avctx->skip_frame >= AVDISCARD_NONINTRA &&
989 (avctx->skip_frame >= AVDISCARD_NONKEY &&
991 avctx->skip_frame >= AVDISCARD_ALL)
994 ret = av1_frame_alloc(avctx, &s->cur_frame);
996 av_log(avctx, AV_LOG_ERROR,
1009 static int av1_decode_frame(AVCodecContext *avctx, AVFrame *frame,
1012 AV1DecContext *s = avctx->priv_data;
1018 av_log(avctx, AV_LOG_ERROR, "Failed to read packet.\n");
1021 av_log(avctx, AV_LOG_DEBUG, "Total obu for this frame:%d.\n",
1033 av_log(avctx, AV_LOG_DEBUG, "Obu idx:%d, obu type:%d.\n", i, unit->type);
1046 ret = set_context_with_sequence(avctx, s->raw_seq);
1048 av_log(avctx, AV_LOG_ERROR, "Failed to set context.\n");
1056 ret = get_pixel_format(avctx);
1058 av_log(avctx, AV_LOG_ERROR,
1065 if (avctx->hwaccel && avctx->hwaccel->decode_params) {
1066 ret = avctx->hwaccel->decode_params(avctx, unit->type, unit->data,
1069 av_log(avctx, AV_LOG_ERROR, "HW accel decode params fail.\n");
1082 av_log(avctx, AV_LOG_ERROR, "Missing Sequence Header.\n");
1100 av1_frame_unref(avctx, &s->cur_frame);
1102 ret = av1_frame_ref(avctx, &s->cur_frame,
1105 av_log(avctx, AV_LOG_ERROR, "Failed to get reference frame.\n");
1109 ret = update_reference_list(avctx);
1111 av_log(avctx, AV_LOG_ERROR, "Failed to update reference list.\n");
1116 ret = set_output_frame(avctx, frame, pkt, got_frame);
1118 av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n");
1126 ret = get_current_frame(avctx);
1128 av_log(avctx, AV_LOG_ERROR, "Get current frame error\n");
1135 if (avctx->hwaccel && s->cur_frame.f->buf[0]) {
1136 ret = avctx->hwaccel->start_frame(avctx, unit->data,
1139 av_log(avctx, AV_LOG_ERROR, "HW accel start frame fail.\n");
1148 av_log(avctx, AV_LOG_ERROR, "Missing Frame Header.\n");
1158 ret = get_tiles_info(avctx, raw_tile_group);
1162 if (avctx->hwaccel && s->cur_frame.f->buf[0]) {
1163 ret = avctx->hwaccel->decode_slice(avctx,
1167 av_log(avctx, AV_LOG_ERROR,
1179 av_log(avctx, AV_LOG_DEBUG,
1185 if (avctx->hwaccel && s->cur_frame.f->buf[0]) {
1186 ret = avctx->hwaccel->end_frame(avctx);
1188 av_log(avctx, AV_LOG_ERROR, "HW accel end frame fail.\n");
1193 ret = update_reference_list(avctx);
1195 av_log(avctx, AV_LOG_ERROR, "Failed to update reference list.\n");
1200 ret = set_output_frame(avctx, frame, pkt, got_frame);
1202 av_log(avctx, AV_LOG_ERROR, "Set output frame error\n");
1218 static void av1_decode_flush(AVCodecContext *avctx)
1220 AV1DecContext *s = avctx->priv_data;
1223 av1_frame_unref(avctx, &s->ref[i]);
1225 av1_frame_unref(avctx, &s->cur_frame);