1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

lavc: move SANE_NB_CHANNELS to internal.h and use it in the PCM decoders

This commit is contained in:
Justin Ruggles
2012-10-22 13:40:10 -04:00
parent 6b07830a77
commit bb6941af2a
3 changed files with 5 additions and 6 deletions

View File

@@ -30,6 +30,8 @@
#include "libavutil/pixfmt.h" #include "libavutil/pixfmt.h"
#include "avcodec.h" #include "avcodec.h"
#define FF_SANE_NB_CHANNELS 128U
typedef struct InternalBuffer { typedef struct InternalBuffer {
uint8_t *base[AV_NUM_DATA_POINTERS]; uint8_t *base[AV_NUM_DATA_POINTERS];
uint8_t *data[AV_NUM_DATA_POINTERS]; uint8_t *data[AV_NUM_DATA_POINTERS];

View File

@@ -31,8 +31,6 @@
#include "mathops.h" #include "mathops.h"
#include "pcm_tablegen.h" #include "pcm_tablegen.h"
#define MAX_CHANNELS 64
static av_cold int pcm_encode_init(AVCodecContext *avctx) static av_cold int pcm_encode_init(AVCodecContext *avctx)
{ {
avctx->frame_size = 0; avctx->frame_size = 0;
@@ -210,7 +208,7 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
PCMDecode *s = avctx->priv_data; PCMDecode *s = avctx->priv_data;
int i; int i;
if (avctx->channels <= 0 || avctx->channels > MAX_CHANNELS) { if (avctx->channels <= 0) {
av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n"); av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
@@ -340,7 +338,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
break; break;
case AV_CODEC_ID_PCM_S16LE_PLANAR: case AV_CODEC_ID_PCM_S16LE_PLANAR:
{ {
const uint8_t *src2[MAX_CHANNELS]; const uint8_t *src2[FF_SANE_NB_CHANNELS];
n /= avctx->channels; n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) for (c = 0; c < avctx->channels; c++)
src2[c] = &src[c * n * 2]; src2[c] = &src[c * n * 2];

View File

@@ -758,8 +758,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
if (av_codec_is_decoder(codec)) if (av_codec_is_decoder(codec))
av_freep(&avctx->subtitle_header); av_freep(&avctx->subtitle_header);
#define SANE_NB_CHANNELS 128U if (avctx->channels > FF_SANE_NB_CHANNELS) {
if (avctx->channels > SANE_NB_CHANNELS) {
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
goto free_and_end; goto free_and_end;
} }