History

avcodec/aptxenc: Process data in complete blocks of four samples only

Do this by setting AVCodecInternal.pad_samples. This prevents reading into the frame's padding and writing into the packet's padding. This actually happened in our FATE tests (where the number of samples is 2 mod 4), which therefore needed to be updated.

Andreas Rheinhardt committed 5 years ago

Commit 129cbbd1 parent 017d9763 files · +8 −6Browse files

Unified · Split

3 files
  1. libavcodec/aptxenc.c +4 −2
  2. tests/ref/fate/aptx +2 −2
  3. tests/ref/fate/aptx-hd +2 −2
libavcodec/aptxenc.c+4−2
@@ -27,6 +27,7 @@ · 26 unmodified lines
27#include "audio_frame_queue.h"27#include "audio_frame_queue.h"
28#include "codec_internal.h"28#include "codec_internal.h"
29#include "encode.h"29#include "encode.h"
30#include "internal.h"
30 31
31typedef struct AptXEncContext {32typedef struct AptXEncContext {
32 AptXContext common;33 AptXContext common;
@@ -259,6 +260,7 @@ static av_cold int aptx_encode_init(AVCodecContext *avctx) · 226 unmodified lines
259 260
260 if (!avctx->frame_size || avctx->frame_size % 4)261 if (!avctx->frame_size || avctx->frame_size % 4)
261 avctx->frame_size = 1024;262 avctx->frame_size = 1024;
263 avctx->internal->pad_samples = 4;
262 264
263 return ff_aptx_init(avctx);265 return ff_aptx_init(avctx);
264}266}
@@ -269,7 +271,7 @@ const FFCodec ff_aptx_encoder = { · 4 unmodified lines
269 CODEC_LONG_NAME("aptX (Audio Processing Technology for Bluetooth)"),271 CODEC_LONG_NAME("aptX (Audio Processing Technology for Bluetooth)"),
270 .p.type = AVMEDIA_TYPE_AUDIO,272 .p.type = AVMEDIA_TYPE_AUDIO,
271 .p.id = AV_CODEC_ID_APTX,273 .p.id = AV_CODEC_ID_APTX,
272 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME,274 .p.capabilities = AV_CODEC_CAP_DR1,
273 .priv_data_size = sizeof(AptXEncContext),275 .priv_data_size = sizeof(AptXEncContext),
274 .init = aptx_encode_init,276 .init = aptx_encode_init,
275 FF_CODEC_ENCODE_CB(aptx_encode_frame),277 FF_CODEC_ENCODE_CB(aptx_encode_frame),
@@ -290,7 +292,7 @@ const FFCodec ff_aptx_hd_encoder = { · 14 unmodified lines
290 CODEC_LONG_NAME("aptX HD (Audio Processing Technology for Bluetooth)"),292 CODEC_LONG_NAME("aptX HD (Audio Processing Technology for Bluetooth)"),
291 .p.type = AVMEDIA_TYPE_AUDIO,293 .p.type = AVMEDIA_TYPE_AUDIO,
292 .p.id = AV_CODEC_ID_APTX_HD,294 .p.id = AV_CODEC_ID_APTX_HD,
293 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME,295 .p.capabilities = AV_CODEC_CAP_DR1,
294 .priv_data_size = sizeof(AptXEncContext),296 .priv_data_size = sizeof(AptXEncContext),
295 .init = aptx_encode_init,297 .init = aptx_encode_init,
296 FF_CODEC_ENCODE_CB(aptx_encode_frame),298 FF_CODEC_ENCODE_CB(aptx_encode_frame),
tests/ref/fate/aptx+2−2
@@ -1,5 +1,5 @@
1b5d8a297c0e8d9854f19d9d3e8b82859 *tests/data/fate/aptx.aptx197dfd7f32d34fb74337c0f6c66e26e2d *tests/data/fate/aptx.aptx
2418950 tests/data/fate/aptx.aptx2418952 tests/data/fate/aptx.aptx
3#tb 0: 1/441003#tb 0: 1/44100
4#media_type 0: audio4#media_type 0: audio
5#codec_id 0: pcm_s16le5#codec_id 0: pcm_s16le
tests/ref/fate/aptx-hd+2−2
@@ -1,5 +1,5 @@
148ecaa81ee5adaaa62ed3ff6574b6666 *tests/data/fate/aptx-hd.aptx_hd16126e414af1acb193e24fdf33c7cac2e *tests/data/fate/aptx-hd.aptx_hd
2628425 tests/data/fate/aptx-hd.aptx_hd2628428 tests/data/fate/aptx-hd.aptx_hd
3#tb 0: 1/441003#tb 0: 1/44100
4#media_type 0: audio4#media_type 0: audio
5#codec_id 0: pcm_s32le5#codec_id 0: pcm_s32le

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t