Skip to content
Snippets Groups Projects
Commit 3abf9373 authored by François Cartegnie's avatar François Cartegnie :fingers_crossed: Committed by Steve Lhomme
Browse files

avcodec: add a define to test for AVCodecContext.ch_layout availability


Co-authored-by: default avatarSteve Lhomme <robux4@ycbcr.xyz>
parent bece856e
No related branches found
No related tags found
1 merge request!5636avcodec: add a define to test for AVCodecContext.ch_layout availability
Pipeline #486166 passed with stage
in 11 minutes and 55 seconds
......@@ -40,6 +40,8 @@
#include <libavcodec/avcodec.h>
#include <libavutil/mem.h>
#define API_CHANNEL_LAYOUT_STRUCT (LIBAVCODEC_VERSION_CHECK(59, 24, 100)) // AVCodecContext.ch_layout
#include <libavutil/channel_layout.h>
......@@ -138,7 +140,7 @@ static int OpenAudioCodec( decoder_t *p_dec )
}
ctx->sample_rate = p_dec->fmt_in->audio.i_rate;
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
#if API_CHANNEL_LAYOUT_STRUCT && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_default( &ctx->ch_layout, p_dec->fmt_in->audio.i_channels );
#else
ctx->channels = p_dec->fmt_in->audio.i_channels;
......@@ -598,7 +600,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
p_dec->fmt_out.audio.i_rate = p_sys->p_context->sample_rate;
/* */
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
#if API_CHANNEL_LAYOUT_STRUCT
if( p_sys->i_previous_channels == p_sys->p_context->ch_layout.nb_channels &&
p_sys->i_previous_layout == p_sys->p_context->ch_layout.u.mask )
return;
......@@ -621,7 +623,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
uint32_t pi_order_src[AOUT_CHAN_MAX] = { 0 };
int i_channels_src = 0;
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
#if API_CHANNEL_LAYOUT_STRUCT
uint64_t channel_layout_mask = p_sys->p_context->ch_layout.u.mask;
int channel_count = p_sys->p_context->ch_layout.nb_channels;
#else
......
......@@ -48,6 +48,8 @@
#include "avcodec.h"
#include "avcommon.h"
#define API_CHANNEL_LAYOUT_STRUCT (LIBAVCODEC_VERSION_CHECK(59, 24, 100)) // AVCodecContext.ch_layout
#define HURRY_UP_GUARD1 VLC_TICK_FROM_MS(450)
#define HURRY_UP_GUARD2 VLC_TICK_FROM_MS(300)
#define HURRY_UP_GUARD3 VLC_TICK_FROM_MS(100)
......@@ -172,7 +174,7 @@ static const uint64_t pi_channels_map[][2] =
{ AV_CH_STEREO_RIGHT, 0 },
};
#if !LIBAVCODEC_VERSION_CHECK(59, 24, 100)
#if !API_CHANNEL_LAYOUT_STRUCT
static const uint32_t channel_mask[][2] = {
{0,0},
{AOUT_CHAN_CENTER, AV_CH_LAYOUT_MONO},
......@@ -778,7 +780,7 @@ int InitVideoEnc( vlc_object_t *p_this )
int i_channels_src = 0;
msg_Dbg( p_enc, "Creating channel order for reordering");
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
#if API_CHANNEL_LAYOUT_STRUCT && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_default( &p_context->ch_layout, p_enc->fmt_out.audio.i_channels );
uint64_t channel_mask = p_context->ch_layout.u.mask;
#else
......@@ -933,7 +935,7 @@ errmsg:
if( p_enc->fmt_out.audio.i_channels > 2 )
{
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
#if API_CHANNEL_LAYOUT_STRUCT && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_default( &p_context->ch_layout, 2 );
#else
p_context->channels = 2;
......@@ -1298,7 +1300,7 @@ static block_t *handle_delay_buffer( encoder_t *p_enc, encoder_sys_t *p_sys, uns
av_frame_unref( p_sys->frame );
p_sys->frame->format = p_sys->p_context->sample_fmt;
p_sys->frame->nb_samples = leftover_samples + p_sys->i_samples_delay;
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
#if API_CHANNEL_LAYOUT_STRUCT && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_copy(&p_sys->frame->ch_layout, &p_sys->p_context->ch_layout);
#else
p_sys->frame->channel_layout = p_sys->p_context->channel_layout;
......@@ -1432,7 +1434,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
else
p_sys->frame->nb_samples = p_sys->i_frame_size;
p_sys->frame->format = p_sys->p_context->sample_fmt;
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
#if API_CHANNEL_LAYOUT_STRUCT && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_copy(&p_sys->frame->ch_layout, &p_sys->p_context->ch_layout);
#else
p_sys->frame->channel_layout = p_sys->p_context->channel_layout;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment