From patchwork Wed Feb 24 10:03:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 25940 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E009944B9E9 for ; Wed, 24 Feb 2021 12:04:10 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B231068A5A8; Wed, 24 Feb 2021 12:04:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 26FCC68004A for ; Wed, 24 Feb 2021 12:04:05 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D7083240694 for ; Wed, 24 Feb 2021 11:04:04 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id b0Zhe3auVsww for ; Wed, 24 Feb 2021 11:04:04 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 676C524048A for ; Wed, 24 Feb 2021 11:04:04 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 28E1B3A01E6; Wed, 24 Feb 2021 11:04:04 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Feb 2021 11:03:58 +0100 Message-Id: <20210224100402.22300-1-anton@khirnov.net> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] tests/api-band-test: simplify code X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- tests/api/api-band-test.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c index 34bed1d6be..717c9441a4 100644 --- a/tests/api/api-band-test.c +++ b/tests/api/api-band-test.c @@ -167,10 +167,8 @@ static int video_decode(const char *input_filename) continue; } - if (result < 0) - result = avcodec_send_packet(ctx, NULL); - else - result = avcodec_send_packet(ctx, pkt); + // pkt will be empty on read error/EOF + result = avcodec_send_packet(ctx, pkt); av_packet_unref(pkt); From patchwork Wed Feb 24 10:03:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 25944 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 618A644B9E9 for ; Wed, 24 Feb 2021 12:04:16 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4318468A901; Wed, 24 Feb 2021 12:04:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EB17668A646 for ; Wed, 24 Feb 2021 12:04:05 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 92418240692 for ; Wed, 24 Feb 2021 11:04:05 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id QUwZnBKOKq9O for ; Wed, 24 Feb 2021 11:04:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 6C14824068A for ; Wed, 24 Feb 2021 11:04:04 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 2A6793A0135; Wed, 24 Feb 2021 11:04:04 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Feb 2021 11:03:59 +0100 Message-Id: <20210224100402.22300-2-anton@khirnov.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210224100402.22300-1-anton@khirnov.net> References: <20210224100402.22300-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] tests/api-flac-test: ensure the frame is writable before writing to it X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The encoder may keep a reference to frames that were sent to it, so the caller cannot modify them without checking first. --- tests/api/api-flac-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c index 3fea3258f3..7c96a4d99e 100644 --- a/tests/api/api-flac-test.c +++ b/tests/api/api-flac-test.c @@ -154,6 +154,10 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, enc_pkt.data = NULL; enc_pkt.size = 0; + result = av_frame_make_writable(in_frame); + if (result < 0) + return result; + generate_raw_frame((uint16_t*)(in_frame->data[0]), i, enc_ctx->sample_rate, enc_ctx->channels, enc_ctx->frame_size); in_frame_bytes = in_frame->nb_samples * in_frame->channels * sizeof(uint16_t); From patchwork Wed Feb 24 10:04:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 25942 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 3D45044B9E9 for ; Wed, 24 Feb 2021 12:04:14 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2D8F768A8E2; Wed, 24 Feb 2021 12:04:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B812868A646 for ; Wed, 24 Feb 2021 12:04:05 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 42F66240693 for ; Wed, 24 Feb 2021 11:04:05 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id njWC4_tsE0Je for ; Wed, 24 Feb 2021 11:04:04 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 6A153240684 for ; Wed, 24 Feb 2021 11:04:04 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 2F0043A01F3; Wed, 24 Feb 2021 11:04:04 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Feb 2021 11:04:00 +0100 Message-Id: <20210224100402.22300-3-anton@khirnov.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210224100402.22300-1-anton@khirnov.net> References: <20210224100402.22300-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] tests/api-flac-test: convert to new encoding/decoding API X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- tests/api/api-flac-test.c | 40 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c index 7c96a4d99e..3d83c56987 100644 --- a/tests/api/api-flac-test.c +++ b/tests/api/api-flac-test.c @@ -113,7 +113,6 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, uint8_t *raw_in = NULL, *raw_out = NULL; int in_offset = 0, out_offset = 0; int result = 0; - int got_output = 0; int i = 0; int in_frame_bytes, out_frame_bytes; @@ -167,25 +166,40 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, } memcpy(raw_in + in_offset, in_frame->data[0], in_frame_bytes); in_offset += in_frame_bytes; - result = avcodec_encode_audio2(enc_ctx, &enc_pkt, in_frame, &got_output); + result = avcodec_send_frame(enc_ctx, in_frame); if (result < 0) { - av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n"); + av_log(NULL, AV_LOG_ERROR, "Error submitting a frame for encoding\n"); return result; } - /* if we get an encoded packet, feed it straight to the decoder */ - if (got_output) { - result = avcodec_decode_audio4(dec_ctx, out_frame, &got_output, &enc_pkt); + while (result >= 0) { + result = avcodec_receive_packet(enc_ctx, &enc_pkt); + if (result == AVERROR(EAGAIN)) + break; + else if (result < 0 && result != AVERROR_EOF) { + av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n"); + return result; + } + + /* if we get an encoded packet, feed it straight to the decoder */ + result = avcodec_send_packet(dec_ctx, &enc_pkt); + av_packet_unref(&enc_pkt); if (result < 0) { - av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n"); + av_log(NULL, AV_LOG_ERROR, "Error submitting a packet for decoding\n"); return result; } - if (got_output) { - if (result != enc_pkt.size) { - av_log(NULL, AV_LOG_INFO, "Decoder consumed only part of a packet, it is allowed to do so -- need to update this test\n"); - return AVERROR_UNKNOWN; - } + result = avcodec_receive_frame(dec_ctx, out_frame); + if (result == AVERROR(EAGAIN)) { + result = 0; + continue; + } else if (result == AVERROR(EOF)) { + result = 0; + break; + } else if (result < 0) { + av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n"); + return result; + } if (in_frame->nb_samples != out_frame->nb_samples) { av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different number of samples\n"); @@ -208,9 +222,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, } memcpy(raw_out + out_offset, out_frame->data[0], out_frame_bytes); out_offset += out_frame_bytes; - } } - av_packet_unref(&enc_pkt); } if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_AUDIO_FRAMES) != 0) { From patchwork Wed Feb 24 10:04:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 25943 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 38E8844B9E9 for ; Wed, 24 Feb 2021 12:04:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2120468A7E9; Wed, 24 Feb 2021 12:04:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D80D068A72F for ; Wed, 24 Feb 2021 12:04:05 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7E05F240684 for ; Wed, 24 Feb 2021 11:04:05 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Y60AoLOFJNKu for ; Wed, 24 Feb 2021 11:04:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 73D75240692 for ; Wed, 24 Feb 2021 11:04:04 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 3293B3A01F4; Wed, 24 Feb 2021 11:04:04 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Feb 2021 11:04:01 +0100 Message-Id: <20210224100402.22300-4-anton@khirnov.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210224100402.22300-1-anton@khirnov.net> References: <20210224100402.22300-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] tests/api-flac-test: reindent X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- tests/api/api-flac-test.c | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c index 3d83c56987..b67c3d7363 100644 --- a/tests/api/api-flac-test.c +++ b/tests/api/api-flac-test.c @@ -201,27 +201,27 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, return result; } - if (in_frame->nb_samples != out_frame->nb_samples) { - av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different number of samples\n"); - return AVERROR_UNKNOWN; - } - - if (in_frame->channel_layout != out_frame->channel_layout) { - av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different channel layout\n"); - return AVERROR_UNKNOWN; - } - - if (in_frame->format != out_frame->format) { - av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different sample format\n"); - return AVERROR_UNKNOWN; - } - out_frame_bytes = out_frame->nb_samples * out_frame->channels * sizeof(uint16_t); - if (out_frame_bytes > out_frame->linesize[0]) { - av_log(NULL, AV_LOG_ERROR, "Incorrect value of output frame linesize\n"); - return 1; - } - memcpy(raw_out + out_offset, out_frame->data[0], out_frame_bytes); - out_offset += out_frame_bytes; + if (in_frame->nb_samples != out_frame->nb_samples) { + av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different number of samples\n"); + return AVERROR_UNKNOWN; + } + + if (in_frame->channel_layout != out_frame->channel_layout) { + av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different channel layout\n"); + return AVERROR_UNKNOWN; + } + + if (in_frame->format != out_frame->format) { + av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different sample format\n"); + return AVERROR_UNKNOWN; + } + out_frame_bytes = out_frame->nb_samples * out_frame->channels * sizeof(uint16_t); + if (out_frame_bytes > out_frame->linesize[0]) { + av_log(NULL, AV_LOG_ERROR, "Incorrect value of output frame linesize\n"); + return 1; + } + memcpy(raw_out + out_offset, out_frame->data[0], out_frame_bytes); + out_offset += out_frame_bytes; } } From patchwork Wed Feb 24 10:04:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 25941 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4A0C144B9E9 for ; Wed, 24 Feb 2021 12:04:13 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2730968A7E6; Wed, 24 Feb 2021 12:04:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8423568004A for ; Wed, 24 Feb 2021 12:04:05 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 1D28224048A for ; Wed, 24 Feb 2021 11:04:05 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id rMtkJFtW19QK for ; Wed, 24 Feb 2021 11:04:04 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 75932240693 for ; Wed, 24 Feb 2021 11:04:04 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 369403A01F5; Wed, 24 Feb 2021 11:04:04 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Feb 2021 11:04:02 +0100 Message-Id: <20210224100402.22300-5-anton@khirnov.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210224100402.22300-1-anton@khirnov.net> References: <20210224100402.22300-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/5] lavc: remove tests/options X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It tests deprecated avcodec_copy_context(). --- libavcodec/Makefile | 1 - libavcodec/tests/options.c | 194 ------------------------------------- tests/fate/libavcodec.mak | 4 - 3 files changed, 199 deletions(-) delete mode 100644 libavcodec/tests/options.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b46c1688cc..097e7ecd5a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1220,7 +1220,6 @@ TESTPROGS = avpacket \ imgconvert \ jpeg2000dwt \ mathops \ - options \ mjpegenc_huffman \ utils \ diff --git a/libavcodec/tests/options.c b/libavcodec/tests/options.c deleted file mode 100644 index 010e3c0145..0000000000 --- a/libavcodec/tests/options.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2001 Fabrice Bellard - * Copyright (c) 2002-2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libavcodec/options.c" - -static int dummy_init(AVCodecContext *ctx) -{ - //TODO: this code should set every possible pointer that could be set by codec and is not an option; - ctx->extradata_size = 8; - ctx->extradata = av_malloc(ctx->extradata_size); - return 0; -} - -static int dummy_close(AVCodecContext *ctx) -{ - av_freep(&ctx->extradata); - ctx->extradata_size = 0; - return 0; -} - -static int dummy_encode(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) -{ - return AVERROR(ENOSYS); -} - -typedef struct Dummy12Context { - AVClass *av_class; - int num; - char* str; -} Dummy12Context; - -typedef struct Dummy3Context { - void *fake_av_class; - int num; - char* str; -} Dummy3Context; - -#define OFFSET(x) offsetof(Dummy12Context, x) -#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM -static const AVOption dummy_options[] = { - { "str", "set str", OFFSET(str), AV_OPT_TYPE_STRING, { .str = "i'm src default value" }, 0, 0, VE}, - { "num", "set num", OFFSET(num), AV_OPT_TYPE_INT, { .i64 = 1500100900 }, 0, INT_MAX, VE}, - { NULL }, -}; - -static const AVClass dummy_v1_class = { - .class_name = "dummy_v1_class", - .item_name = av_default_item_name, - .option = dummy_options, - .version = LIBAVUTIL_VERSION_INT, -}; - -static const AVClass dummy_v2_class = { - .class_name = "dummy_v2_class", - .item_name = av_default_item_name, - .option = dummy_options, - .version = LIBAVUTIL_VERSION_INT, -}; - -/* codec with options */ -static AVCodec dummy_v1_encoder = { - .name = "dummy_v1_codec", - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_NONE - 1, - .encode2 = dummy_encode, - .init = dummy_init, - .close = dummy_close, - .priv_class = &dummy_v1_class, - .priv_data_size = sizeof(Dummy12Context), -}; - -/* codec with options, different class */ -static AVCodec dummy_v2_encoder = { - .name = "dummy_v2_codec", - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_NONE - 2, - .encode2 = dummy_encode, - .init = dummy_init, - .close = dummy_close, - .priv_class = &dummy_v2_class, - .priv_data_size = sizeof(Dummy12Context), -}; - -/* codec with priv data, but no class */ -static AVCodec dummy_v3_encoder = { - .name = "dummy_v3_codec", - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_NONE - 3, - .encode2 = dummy_encode, - .init = dummy_init, - .close = dummy_close, - .priv_data_size = sizeof(Dummy3Context), -}; - -/* codec without priv data */ -static AVCodec dummy_v4_encoder = { - .name = "dummy_v4_codec", - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_NONE - 4, - .encode2 = dummy_encode, - .init = dummy_init, - .close = dummy_close, -}; - -static void test_copy_print_codec(const AVCodecContext *ctx) -{ - printf("%-14s: %dx%d prv: %s", - ctx->codec ? ctx->codec->name : "NULL", - ctx->width, ctx->height, - ctx->priv_data ? "set" : "null"); - if (ctx->codec && ctx->codec->priv_class && ctx->codec->priv_data_size) { - int64_t i64; - char *str = NULL; - av_opt_get_int(ctx->priv_data, "num", 0, &i64); - av_opt_get(ctx->priv_data, "str", 0, (uint8_t**)&str); - printf(" opts: %"PRId64" %s", i64, str); - av_free(str); - } - printf("\n"); -} - -static void test_copy(const AVCodec *c1, const AVCodec *c2) -{ - AVCodecContext *ctx1, *ctx2; - printf("%s -> %s\nclosed:\n", c1 ? c1->name : "NULL", c2 ? c2->name : "NULL"); - ctx1 = avcodec_alloc_context3(c1); - ctx2 = avcodec_alloc_context3(c2); - ctx1->width = ctx1->height = 128; - ctx1->time_base = (AVRational){12,34}; - if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) { - av_opt_set(ctx2->priv_data, "num", "667", 0); - av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0); - } - avcodec_copy_context(ctx2, ctx1); - test_copy_print_codec(ctx1); - test_copy_print_codec(ctx2); - if (ctx1->codec) { - int ret; - printf("opened:\n"); - ret = avcodec_open2(ctx1, ctx1->codec, NULL); - if (ret < 0) { - fprintf(stderr, "avcodec_open2 failed\n"); - exit(1); - } - if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) { - av_opt_set(ctx2->priv_data, "num", "667", 0); - av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0); - } - avcodec_copy_context(ctx2, ctx1); - test_copy_print_codec(ctx1); - test_copy_print_codec(ctx2); - } - avcodec_free_context(&ctx1); - avcodec_free_context(&ctx2); -} - -int main(void) -{ - AVCodec *dummy_codec[] = { - &dummy_v1_encoder, - &dummy_v2_encoder, - &dummy_v3_encoder, - &dummy_v4_encoder, - NULL, - }; - int i, j; - - for (i = 0; dummy_codec[i]; i++) - avcodec_register(dummy_codec[i]); - - printf("testing avcodec_copy_context()\n"); - for (i = 0; i < FF_ARRAY_ELEMS(dummy_codec); i++) - for (j = 0; j < FF_ARRAY_ELEMS(dummy_codec); j++) - test_copy(dummy_codec[i], dummy_codec[j]); - return 0; -} diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak index 747dae3704..682296914a 100644 --- a/tests/fate/libavcodec.mak +++ b/tests/fate/libavcodec.mak @@ -65,10 +65,6 @@ fate-mpeg12framerate: libavcodec/tests/mpeg12framerate$(EXESUF) fate-mpeg12framerate: CMD = run libavcodec/tests/mpeg12framerate$(EXESUF) fate-mpeg12framerate: REF = /dev/null -FATE_LIBAVCODEC-yes += fate-libavcodec-options -fate-libavcodec-options: libavcodec/tests/options$(EXESUF) -fate-libavcodec-options: CMD = run libavcodec/tests/options$(EXESUF) - FATE_LIBAVCODEC-$(CONFIG_RANGECODER) += fate-rangecoder fate-rangecoder: libavcodec/tests/rangecoder$(EXESUF) fate-rangecoder: CMD = run libavcodec/tests/rangecoder$(EXESUF)