1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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; return 0;
} }

View File

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

View File

@ -24,9 +24,15 @@
#include "libavutil/channel_layout.h" #include "libavutil/channel_layout.h"
#include "aptx.h" #include "aptx.h"
#include "audio_frame_queue.h"
#include "codec_internal.h" #include "codec_internal.h"
#include "encode.h" #include "encode.h"
typedef struct AptXEncContext {
AptXContext common;
AudioFrameQueue afq;
} AptXEncContext;
/* /*
* Half-band QMF analysis filter realized with a polyphase FIR filter. * Half-band QMF analysis filter realized with a polyphase FIR filter.
* Split into 2 subbands and downsample by 2. * 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, static int aptx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr) 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; 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; return ret;
output_size = s->block_size * frame->nb_samples/4; 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); 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; *got_packet_ptr = 1;
return 0; return 0;
} }
static av_cold int aptx_close(AVCodecContext *avctx) 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); ff_af_queue_close(&s->afq);
return 0; 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 #if CONFIG_APTX_ENCODER
const FFCodec ff_aptx_encoder = { const FFCodec ff_aptx_encoder = {
.p.name = "aptx", .p.name = "aptx",
@ -251,8 +267,8 @@ const FFCodec ff_aptx_encoder = {
.p.type = AVMEDIA_TYPE_AUDIO, .p.type = AVMEDIA_TYPE_AUDIO,
.p.id = AV_CODEC_ID_APTX, .p.id = AV_CODEC_ID_APTX,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME,
.priv_data_size = sizeof(AptXContext), .priv_data_size = sizeof(AptXEncContext),
.init = ff_aptx_init, .init = aptx_encode_init,
FF_CODEC_ENCODE_CB(aptx_encode_frame), FF_CODEC_ENCODE_CB(aptx_encode_frame),
.close = aptx_close, .close = aptx_close,
#if FF_API_OLD_CHANNEL_LAYOUT #if FF_API_OLD_CHANNEL_LAYOUT
@ -272,8 +288,8 @@ const FFCodec ff_aptx_hd_encoder = {
.p.type = AVMEDIA_TYPE_AUDIO, .p.type = AVMEDIA_TYPE_AUDIO,
.p.id = AV_CODEC_ID_APTX_HD, .p.id = AV_CODEC_ID_APTX_HD,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME,
.priv_data_size = sizeof(AptXContext), .priv_data_size = sizeof(AptXEncContext),
.init = ff_aptx_init, .init = aptx_encode_init,
FF_CODEC_ENCODE_CB(aptx_encode_frame), FF_CODEC_ENCODE_CB(aptx_encode_frame),
.close = aptx_close, .close = aptx_close,
#if FF_API_OLD_CHANNEL_LAYOUT #if FF_API_OLD_CHANNEL_LAYOUT