From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 3328742ABA for ; Tue, 11 Jan 2022 12:45:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8639768AF41; Tue, 11 Jan 2022 14:45:42 +0200 (EET) Received: from mail-vk1-f180.google.com (mail-vk1-f180.google.com [209.85.221.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E4698689FD9 for ; Tue, 11 Jan 2022 14:45:35 +0200 (EET) Received: by mail-vk1-f180.google.com with SMTP id 19so2514108vkl.2 for ; Tue, 11 Jan 2022 04:45:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:references:in-reply-to:content-transfer-encoding; bh=vQlz47u2BDDy/V2tY0tc27G2VPBFwFcvUwT8gse3MKk=; b=BGK/L+w983PdPA1p9iF+FJDh7JNI+RLJ2+AUbtznI035t8NEOEuLeSvqh5NN3DY+wA g7oZRnADWKsMdsWoPIDA4L0ZV677s36fhULLLw1SEALBNaqc+TBGHXOCCBWbPTifbBLn kQworz/KCSB5/1YS6XpatV+dclCcYctJlxMWqU/j3TPShQGN2Bu1wPuB5p4s+s1shj+l A5aySRrlhqpgJCv0FwjcWOjqnB2NfdY5pwGB3KazshC1mnD7jHiv6/9489TmmZjr1jnw pmaIaZDtaBwfrxHywGP5f0DpazCQxCPFSlmhqUOvVZV1qFeDClJNBvzilRuapWNly6Yn iX6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:references:in-reply-to :content-transfer-encoding; bh=vQlz47u2BDDy/V2tY0tc27G2VPBFwFcvUwT8gse3MKk=; b=ADfiqTWXrj0ZYlRMm40b7FK2ifyKZcdjzK7rSFb+msSM+wgSPH0E/12GUYFoQXxSsQ 4pW7OF4sAzgTLewucQtQk9T4Wi/J5f8wbG1GNJ8IdJxDN/9JbN6CBnR/k17XWPxRX92j DSl1bxh+jUjbnyMahfuzNSivYkk5+DZ8MBhzkXRDmqbtDEb49S8UlOYmaAn4gJzWiI0d DD6BchE5BujhaYc7zjlgE4pPZmxgBQSF4iOmMxeT4AGW8JtDMU5/rWxP3fBLPjTds+Md JMpadPq/npPTTnPc51GsN6taK8SbJ6cU4RhQEzDPxvEv9jxhb4l3rFgGisMAE4a42f4J RYNQ== X-Gm-Message-State: AOAM532M8fgF+7wyd2Wwub52lHNwyf/WS7uIpbSx2HBXEui0wKJmPstf 0eSXhj3X6Mh5LmrSIIJSdBzitmsnqgQ= X-Google-Smtp-Source: ABdhPJx64LPo4tjRQ4jp0JbM5hTQbefuaPTwLrP5iwkia0sMMAJx39GP8EFRGFEKrk2uynjcucr7Tg== X-Received: by 2002:a05:6122:998:: with SMTP id g24mr1901027vkd.22.1641905133443; Tue, 11 Jan 2022 04:45:33 -0800 (PST) Received: from [192.168.0.13] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id e24sm2986014vsk.11.2022.01.11.04.45.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Jan 2022 04:45:32 -0800 (PST) Message-ID: <2efd5730-5116-a439-c96c-afe4febeda03@gmail.com> Date: Tue, 11 Jan 2022 09:45:31 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Content-Language: en-US From: James Almer To: ffmpeg-devel@ffmpeg.org References: <20220109191855.2106-1-jamrial@gmail.com> In-Reply-To: <20220109191855.2106-1-jamrial@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH v2] avcodec/av1dec: honor the requested skip_frame level X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 1/9/2022 4:18 PM, James Almer wrote: > This supports dropping non-intra, non-key, or all frames. > > Signed-off-by: James Almer > --- > Now dropping the frames without decoding them. > > Untested with actual hardware. Tested by nevcairiel and confirmed to work, so will apply. > > libavcodec/av1dec.c | 68 ++++++++++++++++++++++++++------------------- > 1 file changed, 39 insertions(+), 29 deletions(-) > > diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c > index 09df2bf421..62d459cded 100644 > --- a/libavcodec/av1dec.c > +++ b/libavcodec/av1dec.c > @@ -585,16 +585,19 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s > { > int ret; > > - ret = ff_thread_ref_frame(&dst->tf, &src->tf); > + ret = av_buffer_replace(&dst->header_ref, src->header_ref); > if (ret < 0) > return ret; > > - dst->header_ref = av_buffer_ref(src->header_ref); > - if (!dst->header_ref) > - goto fail; > - > dst->raw_frame_header = src->raw_frame_header; > > + if (!src->tf.f->buf[0]) > + return 0; > + > + ret = ff_thread_ref_frame(&dst->tf, &src->tf); > + if (ret < 0) > + goto fail; > + > if (src->hwaccel_picture_private) { > dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); > if (!dst->hwaccel_priv_buf) > @@ -800,12 +803,6 @@ static int av1_frame_alloc(AVCodecContext *avctx, AV1Frame *f) > return ret; > } > > - f->header_ref = av_buffer_ref(s->header_ref); > - if (!f->header_ref) > - return AVERROR(ENOMEM); > - > - f->raw_frame_header = s->raw_frame_header; > - > if ((ret = ff_thread_get_buffer(avctx, &f->tf, AV_GET_BUFFER_FLAG_REF)) < 0) > goto fail; > > @@ -945,8 +942,7 @@ static int update_reference_list(AVCodecContext *avctx) > > for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) { > if (header->refresh_frame_flags & (1 << i)) { > - if (s->ref[i].tf.f->buf[0]) > - av1_frame_unref(avctx, &s->ref[i]); > + av1_frame_unref(avctx, &s->ref[i]); > if ((ret = av1_frame_ref(avctx, &s->ref[i], &s->cur_frame)) < 0) { > av_log(avctx, AV_LOG_ERROR, > "Failed to update frame %d in reference list\n", i); > @@ -962,19 +958,32 @@ static int get_current_frame(AVCodecContext *avctx) > AV1DecContext *s = avctx->priv_data; > int ret; > > - if (s->cur_frame.tf.f->buf[0]) > - av1_frame_unref(avctx, &s->cur_frame); > + av1_frame_unref(avctx, &s->cur_frame); > > - ret = av1_frame_alloc(avctx, &s->cur_frame); > + s->cur_frame.header_ref = av_buffer_ref(s->header_ref); > + if (!s->cur_frame.header_ref) > + return AVERROR(ENOMEM); > + > + s->cur_frame.raw_frame_header = s->raw_frame_header; > + > + ret = init_tile_data(s); > if (ret < 0) { > - av_log(avctx, AV_LOG_ERROR, > - "Failed to allocate space for current frame.\n"); > + av_log(avctx, AV_LOG_ERROR, "Failed to init tile data.\n"); > return ret; > } > > - ret = init_tile_data(s); > + if ((avctx->skip_frame >= AVDISCARD_NONINTRA && > + (s->raw_frame_header->frame_type != AV1_FRAME_KEY && > + s->raw_frame_header->frame_type != AV1_FRAME_INTRA_ONLY)) || > + (avctx->skip_frame >= AVDISCARD_NONKEY && > + s->raw_frame_header->frame_type != AV1_FRAME_KEY) || > + avctx->skip_frame >= AVDISCARD_ALL) > + return 0; > + > + ret = av1_frame_alloc(avctx, &s->cur_frame); > if (ret < 0) { > - av_log(avctx, AV_LOG_ERROR, "Failed to init tile data.\n"); > + av_log(avctx, AV_LOG_ERROR, > + "Failed to allocate space for current frame.\n"); > return ret; > } > > @@ -1077,8 +1086,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, > s->raw_frame_header = &obu->obu.frame_header; > > if (s->raw_frame_header->show_existing_frame) { > - if (s->cur_frame.tf.f->buf[0]) > - av1_frame_unref(avctx, &s->cur_frame); > + av1_frame_unref(avctx, &s->cur_frame); > > ret = av1_frame_ref(avctx, &s->cur_frame, > &s->ref[s->raw_frame_header->frame_to_show_map_idx]); > @@ -1093,9 +1101,11 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, > goto end; > } > > - ret = set_output_frame(avctx, frame, pkt, got_frame); > - if (ret < 0) > - av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n"); > + if (s->cur_frame.tf.f->buf[0]) { > + ret = set_output_frame(avctx, frame, pkt, got_frame); > + if (ret < 0) > + av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n"); > + } > > s->raw_frame_header = NULL; > > @@ -1111,7 +1121,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, > s->cur_frame.spatial_id = header->spatial_id; > s->cur_frame.temporal_id = header->temporal_id; > > - if (avctx->hwaccel) { > + if (avctx->hwaccel && s->cur_frame.tf.f->buf[0]) { > ret = avctx->hwaccel->start_frame(avctx, unit->data, > unit->data_size); > if (ret < 0) { > @@ -1138,7 +1148,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, > if (ret < 0) > goto end; > > - if (avctx->hwaccel) { > + if (avctx->hwaccel && s->cur_frame.tf.f->buf[0]) { > ret = avctx->hwaccel->decode_slice(avctx, > raw_tile_group->tile_data.data, > raw_tile_group->tile_data.data_size); > @@ -1161,7 +1171,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, > } > > if (raw_tile_group && (s->tile_num == raw_tile_group->tg_end + 1)) { > - if (avctx->hwaccel) { > + if (avctx->hwaccel && s->cur_frame.tf.f->buf[0]) { > ret = avctx->hwaccel->end_frame(avctx); > if (ret < 0) { > av_log(avctx, AV_LOG_ERROR, "HW accel end frame fail.\n"); > @@ -1175,7 +1185,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, > goto end; > } > > - if (s->raw_frame_header->show_frame) { > + if (s->raw_frame_header->show_frame && s->cur_frame.tf.f->buf[0]) { > ret = set_output_frame(avctx, frame, pkt, got_frame); > if (ret < 0) { > av_log(avctx, AV_LOG_ERROR, "Set output frame error\n"); _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".