History

avcodec/mpegaudiodec*: Cleanup generically on init failure

Andreas Rheinhardt committed 6 years ago

Commit c7867b61 parent e9831b13 files · +5 −8Browse files

Unified · Split

3 files
  1. libavcodec/mpegaudiodec_fixed.c +1 −0
  2. libavcodec/mpegaudiodec_float.c +1 −0
  3. libavcodec/mpegaudiodec_template.c +3 −8
libavcodec/mpegaudiodec_fixed.c+1−0
@@ -116,5 +116,6 @@ AVCodec ff_mp3on4_decoder = { · 115 unmodified lines
116 .flush = flush_mp3on4,116 .flush = flush_mp3on4,
117 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,117 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
118 AV_SAMPLE_FMT_NONE },118 AV_SAMPLE_FMT_NONE },
119 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
119};120};
120#endif121#endif
libavcodec/mpegaudiodec_float.c+1−0
@@ -116,5 +116,6 @@ AVCodec ff_mp3on4float_decoder = { · 115 unmodified lines
116 .flush = flush_mp3on4,116 .flush = flush_mp3on4,
117 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,117 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
118 AV_SAMPLE_FMT_NONE },118 AV_SAMPLE_FMT_NONE },
119 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
119};120};
120#endif121#endif
libavcodec/mpegaudiodec_template.c+3−8
@@ -1908,16 +1908,14 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) · 1907 unmodified lines
1908 // Allocate zeroed memory for the first decoder context1908 // Allocate zeroed memory for the first decoder context
1909 s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));1909 s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
1910 if (!s->mp3decctx[0])1910 if (!s->mp3decctx[0])
1911 goto alloc_fail;1911 return AVERROR(ENOMEM);
1912 // Put decoder context in place to make init_decode() happy1912 // Put decoder context in place to make init_decode() happy
1913 avctx->priv_data = s->mp3decctx[0];1913 avctx->priv_data = s->mp3decctx[0];
1914 ret = decode_init(avctx);1914 ret = decode_init(avctx);
1915 // Restore mp3on4 context pointer1915 // Restore mp3on4 context pointer
1916 avctx->priv_data = s;1916 avctx->priv_data = s;
1917 if (ret < 0) {1917 if (ret < 0)
1918 decode_close_mp3on4(avctx);
1919 return ret;1918 return ret;
1920 }
1921 s->mp3decctx[0]->adu_mode = 1; // Set adu mode1919 s->mp3decctx[0]->adu_mode = 1; // Set adu mode
1922 1920
1923 /* Create a separate codec/context for each frame (first is already ok).1921 /* Create a separate codec/context for each frame (first is already ok).
@@ -1926,7 +1924,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) · 2 unmodified lines
1926 for (i = 1; i < s->frames; i++) {1924 for (i = 1; i < s->frames; i++) {
1927 s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));1925 s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));
1928 if (!s->mp3decctx[i])1926 if (!s->mp3decctx[i])
1929 goto alloc_fail;1927 return AVERROR(ENOMEM);
1930 s->mp3decctx[i]->adu_mode = 1;1928 s->mp3decctx[i]->adu_mode = 1;
1931 s->mp3decctx[i]->avctx = avctx;1929 s->mp3decctx[i]->avctx = avctx;
1932 s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;1930 s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
@@ -1934,9 +1932,6 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) · 1 unmodified line
1934 }1932 }
1935 1933
1936 return 0;1934 return 0;
1937alloc_fail:
1938 decode_close_mp3on4(avctx);
1939 return AVERROR(ENOMEM);
1940}1935}
1941 1936
1942 1937

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