Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 123 lines 4.4 kB view raw
1From 50741b98fb4b932759f05e8d208d80d93bcc8261 Mon Sep 17 00:00:00 2001 2From: Hugh McMaster <hugh.mcmaster@outlook.com> 3Date: Mon, 29 Jul 2024 23:15:35 +1000 4Subject: [PATCH] src/scan.c: Update for FFmpeg 7.0 5 6--- 7 src/scan.c | 40 +++++++++++++++++++++------------------- 8 1 file changed, 21 insertions(+), 19 deletions(-) 9 10diff --git a/src/scan.c b/src/scan.c 11index 85b36b3..91eb261 100644 12--- a/src/scan.c 13+++ b/src/scan.c 14@@ -119,7 +119,7 @@ int scan_file(const char *file, unsigned index) { 15 AVCodecContext *ctx; 16 17 AVFrame *frame; 18- AVPacket packet; 19+ AVPacket *packet; 20 21 SwrContext *swr; 22 23@@ -177,8 +177,8 @@ int scan_file(const char *file, unsigned index) { 24 } 25 26 // try to get default channel layout (they aren’t specified in .wav files) 27- if (!ctx->channel_layout) 28- ctx->channel_layout = av_get_default_channel_layout(ctx->channels); 29+ if (ctx->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) 30+ av_channel_layout_default(&ctx->ch_layout, ctx->ch_layout.nb_channels); 31 32 // show some information about the file 33 // only show bits/sample where it makes sense 34@@ -187,21 +187,21 @@ int scan_file(const char *file, unsigned index) { 35 snprintf(infotext, sizeof(infotext), "%d bit, ", 36 ctx->bits_per_raw_sample > 0 ? ctx->bits_per_raw_sample : ctx->bits_per_coded_sample); 37 } 38- av_get_channel_layout_string(infobuf, sizeof(infobuf), -1, ctx->channel_layout); 39+ av_channel_layout_describe(&ctx->ch_layout, infobuf, sizeof(infobuf)); 40 ok_printf("Stream #%d: %s, %s%d Hz, %d ch, %s", 41- stream_id, codec->long_name, infotext, ctx->sample_rate, ctx->channels, infobuf); 42+ stream_id, codec->long_name, infotext, ctx->sample_rate, ctx->ch_layout.nb_channels, infobuf); 43 44 scan_codecs[index] = codec -> id; 45 46- av_init_packet(&packet); 47+ packet = av_packet_alloc(); 48 49- packet.data = buffer; 50- packet.size = buffer_size; 51+ packet->data = buffer; 52+ packet->size = buffer_size; 53 54 swr = swr_alloc(); 55 56 *ebur128 = ebur128_init( 57- ctx -> channels, ctx -> sample_rate, 58+ ctx->ch_layout.nb_channels, ctx->sample_rate, 59 EBUR128_MODE_S | EBUR128_MODE_I | EBUR128_MODE_LRA | 60 EBUR128_MODE_SAMPLE_PEAK | EBUR128_MODE_TRUE_PEAK 61 ); 62@@ -222,10 +222,10 @@ int scan_file(const char *file, unsigned index) { 63 64 progress_bar(0, 0, 0, 0); 65 66- while (av_read_frame(container, &packet) >= 0) { 67- if (packet.stream_index == stream_id) { 68+ while (av_read_frame(container, packet) >= 0) { 69+ if (packet->stream_index == stream_id) { 70 71- rc = avcodec_send_packet(ctx, &packet); 72+ rc = avcodec_send_packet(ctx, packet); 73 if (rc < 0) { 74 err_printf("Error while sending a packet to the decoder"); 75 break; 76@@ -252,7 +252,7 @@ int scan_file(const char *file, unsigned index) { 77 av_frame_unref(frame); 78 } 79 80- av_packet_unref(&packet); 81+ av_packet_unref(packet); 82 } 83 84 // complete progress bar for very short files (only cosmetic) 85@@ -263,9 +263,11 @@ int scan_file(const char *file, unsigned index) { 86 87 av_frame_free(&frame); 88 89+ av_packet_free(&packet); 90+ 91 swr_free(&swr); 92 93- avcodec_close(ctx); 94+ avcodec_free_context(&ctx); 95 96 avformat_close_input(&container); 97 98@@ -413,12 +415,12 @@ static void scan_frame(ebur128_state *ebur128, AVFrame *frame, 99 int out_linesize; 100 enum AVSampleFormat out_fmt = AV_SAMPLE_FMT_S16; 101 102- av_opt_set_channel_layout(swr, "in_channel_layout", frame -> channel_layout, 0); 103- av_opt_set_channel_layout(swr, "out_channel_layout", frame -> channel_layout, 0); 104+ av_opt_set_chlayout(swr, "in_chlayout", &frame->ch_layout, 0); 105+ av_opt_set_chlayout(swr, "out_chlayout", &frame->ch_layout, 0); 106 107 // add channel count to properly handle .wav reading 108- av_opt_set_int(swr, "in_channel_count", frame -> channels, 0); 109- av_opt_set_int(swr, "out_channel_count", frame -> channels, 0); 110+ av_opt_set_int(swr, "in_channel_count", frame->ch_layout.nb_channels, 0); 111+ av_opt_set_int(swr, "out_channel_count", frame->ch_layout.nb_channels, 0); 112 113 av_opt_set_int(swr, "in_sample_rate", frame -> sample_rate, 0); 114 av_opt_set_int(swr, "out_sample_rate", frame -> sample_rate, 0); 115@@ -434,7 +436,7 @@ static void scan_frame(ebur128_state *ebur128, AVFrame *frame, 116 } 117 118 out_size = av_samples_get_buffer_size( 119- &out_linesize, frame -> channels, frame -> nb_samples, out_fmt, 0 120+ &out_linesize, frame->ch_layout.nb_channels, frame->nb_samples, out_fmt, 0 121 ); 122 123 out_data = av_malloc(out_size);