avcodec/aptx: Move AudioFrameQueue to aptxenc.c

It is only used by the encoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-08-23 18:12:23 +02:00
parent 8e56e6b2be
commit 18e55de45a
3 changed files with 24 additions and 11 deletions

View File

@ -534,6 +534,5 @@ av_cold int ff_aptx_init(AVCodecContext *avctx)
}
}
ff_af_queue_init(avctx, &s->afq);
return 0;
}

View File

@ -26,7 +26,6 @@
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "mathops.h"
#include "audio_frame_queue.h"
enum channels {
@ -95,7 +94,6 @@ typedef struct {
int block_size;
int32_t sync_idx;
Channel channels[NB_CHANNELS];
AudioFrameQueue afq;
} AptXContext;
typedef const struct {

View File

@ -24,9 +24,15 @@
#include "libavutil/channel_layout.h"
#include "aptx.h"
#include "audio_frame_queue.h"
#include "codec_internal.h"
#include "encode.h"
typedef struct AptXEncContext {
AptXContext common;
AudioFrameQueue afq;
} AptXEncContext;
/*
* Half-band QMF analysis filter realized with a polyphase FIR filter.
* Split into 2 subbands and downsample by 2.
@ -212,10 +218,11 @@ static void aptx_encode_samples(AptXContext *ctx,
static int aptx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
AptXContext *s = avctx->priv_data;
AptXEncContext *const s0 = avctx->priv_data;
AptXContext *const s = &s0->common;
int pos, ipos, channel, sample, output_size, ret;
if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)
if ((ret = ff_af_queue_add(&s0->afq, frame)) < 0)
return ret;
output_size = s->block_size * frame->nb_samples/4;
@ -232,18 +239,27 @@ static int aptx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
aptx_encode_samples(s, samples, avpkt->data + pos);
}
ff_af_queue_remove(&s->afq, frame->nb_samples, &avpkt->pts, &avpkt->duration);
ff_af_queue_remove(&s0->afq, frame->nb_samples, &avpkt->pts, &avpkt->duration);
*got_packet_ptr = 1;
return 0;
}
static av_cold int aptx_close(AVCodecContext *avctx)
{
AptXContext *s = avctx->priv_data;
AptXEncContext *const s = avctx->priv_data;
ff_af_queue_close(&s->afq);
return 0;
}
static av_cold int aptx_encode_init(AVCodecContext *avctx)
{
AptXEncContext *const s = avctx->priv_data;
ff_af_queue_init(avctx, &s->afq);
return ff_aptx_init(avctx);
}
#if CONFIG_APTX_ENCODER
const FFCodec ff_aptx_encoder = {
.p.name = "aptx",
@ -251,8 +267,8 @@ const FFCodec ff_aptx_encoder = {
.p.type = AVMEDIA_TYPE_AUDIO,
.p.id = AV_CODEC_ID_APTX,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME,
.priv_data_size = sizeof(AptXContext),
.init = ff_aptx_init,
.priv_data_size = sizeof(AptXEncContext),
.init = aptx_encode_init,
FF_CODEC_ENCODE_CB(aptx_encode_frame),
.close = aptx_close,
#if FF_API_OLD_CHANNEL_LAYOUT
@ -272,8 +288,8 @@ const FFCodec ff_aptx_hd_encoder = {
.p.type = AVMEDIA_TYPE_AUDIO,
.p.id = AV_CODEC_ID_APTX_HD,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME,
.priv_data_size = sizeof(AptXContext),
.init = ff_aptx_init,
.priv_data_size = sizeof(AptXEncContext),
.init = aptx_encode_init,
FF_CODEC_ENCODE_CB(aptx_encode_frame),
.close = aptx_close,
#if FF_API_OLD_CHANNEL_LAYOUT