History

check for coded_frame allocation failure in several audio encoders

Justin Ruggles committed 14 years ago

Commit a8bdf241 parent 255ad887 files · +17 −0Browse files

Unified · Split

7 files
  1. libavcodec/libgsm.c +4 −0
  2. libavcodec/libopencore-amr.c +3 −0
  3. libavcodec/libvo-aacenc.c +2 −0
  4. libavcodec/libvo-amrwbenc.c +2 −0
  5. libavcodec/mpegaudioenc.c +2 −0
  6. libavcodec/pcm.c +2 −0
  7. libavcodec/roqaudioenc.c +2 −0
libavcodec/libgsm.c+4−0
@@ -70,6 +70,10 @@ static av_cold int libgsm_encode_init(AVCodecContext *avctx) { · 69 unmodified lines
70 }70 }
71 71
72 avctx->coded_frame= avcodec_alloc_frame();72 avctx->coded_frame= avcodec_alloc_frame();
73 if (!avctx->coded_frame) {
74 gsm_destroy(avctx->priv_data);
75 return AVERROR(ENOMEM);
76 }
73 77
74 return 0;78 return 0;
75}79}
libavcodec/libopencore-amr.c+3−0
@@ -196,10 +196,13 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx) · 195 unmodified lines
196 196
197 avctx->frame_size = 160;197 avctx->frame_size = 160;
198 avctx->coded_frame = avcodec_alloc_frame();198 avctx->coded_frame = avcodec_alloc_frame();
199 if (!avctx->coded_frame)
200 return AVERROR(ENOMEM);
199 201
200 s->enc_state = Encoder_Interface_init(s->enc_dtx);202 s->enc_state = Encoder_Interface_init(s->enc_dtx);
201 if (!s->enc_state) {203 if (!s->enc_state) {
202 av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");204 av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
205 av_freep(&avctx->coded_frame);
203 return -1;206 return -1;
204 }207 }
205 208
libavcodec/libvo-aacenc.c+2−0
@@ -39,6 +39,8 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) · 38 unmodified lines
39 int index;39 int index;
40 40
41 avctx->coded_frame = avcodec_alloc_frame();41 avctx->coded_frame = avcodec_alloc_frame();
42 if (!avctx->coded_frame)
43 return AVERROR(ENOMEM);
42 avctx->frame_size = 1024;44 avctx->frame_size = 1024;
43 45
44 voGetAACEncAPI(&s->codec_api);46 voGetAACEncAPI(&s->codec_api);
libavcodec/libvo-amrwbenc.c+2−0
@@ -87,6 +87,8 @@ static av_cold int amr_wb_encode_init(AVCodecContext *avctx) · 86 unmodified lines
87 87
88 avctx->frame_size = 320;88 avctx->frame_size = 320;
89 avctx->coded_frame = avcodec_alloc_frame();89 avctx->coded_frame = avcodec_alloc_frame();
90 if (!avctx->coded_frame)
91 return AVERROR(ENOMEM);
90 92
91 s->state = E_IF_init();93 s->state = E_IF_init();
92 94
libavcodec/mpegaudioenc.c+2−0
@@ -181,6 +181,8 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx) · 180 unmodified lines
181 }181 }
182 182
183 avctx->coded_frame= avcodec_alloc_frame();183 avctx->coded_frame= avcodec_alloc_frame();
184 if (!avctx->coded_frame)
185 return AVERROR(ENOMEM);
184 186
185 return 0;187 return 0;
186}188}
libavcodec/pcm.c+2−0
@@ -49,6 +49,8 @@ static av_cold int pcm_encode_init(AVCodecContext *avctx) · 48 unmodified lines
49 avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);49 avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
50 avctx->block_align = avctx->channels * avctx->bits_per_coded_sample/8;50 avctx->block_align = avctx->channels * avctx->bits_per_coded_sample/8;
51 avctx->coded_frame= avcodec_alloc_frame();51 avctx->coded_frame= avcodec_alloc_frame();
52 if (!avctx->coded_frame)
53 return AVERROR(ENOMEM);
52 54
53 return 0;55 return 0;
54}56}
libavcodec/roqaudioenc.c+2−0
@@ -59,6 +59,8 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) · 58 unmodified lines
59 context->lastSample[0] = context->lastSample[1] = 0;59 context->lastSample[0] = context->lastSample[1] = 0;
60 60
61 avctx->coded_frame= avcodec_alloc_frame();61 avctx->coded_frame= avcodec_alloc_frame();
62 if (!avctx->coded_frame)
63 return AVERROR(ENOMEM);
62 64
63 return 0;65 return 0;
64}66}

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