You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avcodec/cfhd, cfhddata: Free VLC as soon as it is not needed
The VLC is only used to initialize RL VLC. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -1404,9 +1404,6 @@ static av_cold int cfhd_close(AVCodecContext *avctx)
|
|||||||
|
|
||||||
free_buffers(s);
|
free_buffers(s);
|
||||||
|
|
||||||
ff_free_vlc(&s->vlc_9);
|
|
||||||
ff_free_vlc(&s->vlc_18);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "bytestream.h"
|
#include "bytestream.h"
|
||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "vlc.h"
|
|
||||||
#include "cfhddsp.h"
|
#include "cfhddsp.h"
|
||||||
|
|
||||||
enum CFHDParam {
|
enum CFHDParam {
|
||||||
@@ -141,10 +140,7 @@ typedef struct CFHDContext {
|
|||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
|
|
||||||
CFHD_RL_VLC_ELEM table_9_rl_vlc[2088];
|
CFHD_RL_VLC_ELEM table_9_rl_vlc[2088];
|
||||||
VLC vlc_9;
|
|
||||||
|
|
||||||
CFHD_RL_VLC_ELEM table_18_rl_vlc[4572];
|
CFHD_RL_VLC_ELEM table_18_rl_vlc[4572];
|
||||||
VLC vlc_18;
|
|
||||||
|
|
||||||
int lut[2][256];
|
int lut[2][256];
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "libavutil/attributes.h"
|
#include "libavutil/attributes.h"
|
||||||
|
|
||||||
#include "cfhd.h"
|
#include "cfhd.h"
|
||||||
|
#include "vlc.h"
|
||||||
|
|
||||||
#define NB_VLC_TABLE_9 (71 + 3)
|
#define NB_VLC_TABLE_9 (71 + 3)
|
||||||
#define NB_VLC_TABLE_18 (263 + 1)
|
#define NB_VLC_TABLE_18 (263 + 1)
|
||||||
@@ -126,11 +127,12 @@ static const CFHD_RL_ELEM table_18_vlc[NB_VLC_TABLE_18] = {
|
|||||||
|
|
||||||
static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size,
|
static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size,
|
||||||
const CFHD_RL_ELEM table_vlc[], unsigned table_size,
|
const CFHD_RL_ELEM table_vlc[], unsigned table_size,
|
||||||
VLC *vlc, void *logctx)
|
void *logctx)
|
||||||
{
|
{
|
||||||
uint8_t new_cfhd_vlc_len[NB_VLC_TABLE_18 * 2];
|
uint8_t new_cfhd_vlc_len[NB_VLC_TABLE_18 * 2];
|
||||||
uint16_t new_cfhd_vlc_run[NB_VLC_TABLE_18 * 2];
|
uint16_t new_cfhd_vlc_run[NB_VLC_TABLE_18 * 2];
|
||||||
int16_t new_cfhd_vlc_level[NB_VLC_TABLE_18 * 2];
|
int16_t new_cfhd_vlc_level[NB_VLC_TABLE_18 * 2];
|
||||||
|
VLC vlc;
|
||||||
unsigned j;
|
unsigned j;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -151,15 +153,15 @@ static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ff_init_vlc_from_lengths(vlc, VLC_BITS, j, new_cfhd_vlc_len,
|
ret = ff_init_vlc_from_lengths(&vlc, VLC_BITS, j, new_cfhd_vlc_len,
|
||||||
1, NULL, 0, 0, 0, 0, logctx);
|
1, NULL, 0, 0, 0, 0, logctx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
av_assert0(vlc->table_size == out_size);
|
av_assert0(vlc.table_size == out_size);
|
||||||
|
|
||||||
for (unsigned i = 0; i < out_size; i++) {
|
for (unsigned i = 0; i < out_size; i++) {
|
||||||
int code = vlc->table[i].sym;
|
int code = vlc.table[i].sym;
|
||||||
int len = vlc->table[i].len;
|
int len = vlc.table[i].len;
|
||||||
int level, run;
|
int level, run;
|
||||||
|
|
||||||
if (len < 0) { // more bits needed
|
if (len < 0) { // more bits needed
|
||||||
@@ -173,6 +175,7 @@ static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size,
|
|||||||
out[i].level = level;
|
out[i].level = level;
|
||||||
out[i].run = run;
|
out[i].run = run;
|
||||||
}
|
}
|
||||||
|
ff_free_vlc(&vlc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -184,13 +187,13 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s)
|
|||||||
/* Table 9 */
|
/* Table 9 */
|
||||||
ret = cfhd_init_vlc(s->table_9_rl_vlc, FF_ARRAY_ELEMS(s->table_9_rl_vlc),
|
ret = cfhd_init_vlc(s->table_9_rl_vlc, FF_ARRAY_ELEMS(s->table_9_rl_vlc),
|
||||||
table_9_vlc, FF_ARRAY_ELEMS(table_9_vlc),
|
table_9_vlc, FF_ARRAY_ELEMS(table_9_vlc),
|
||||||
&s->vlc_9, s->avctx);
|
s->avctx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
/* Table 18 */
|
/* Table 18 */
|
||||||
ret = cfhd_init_vlc(s->table_18_rl_vlc, FF_ARRAY_ELEMS(s->table_18_rl_vlc),
|
ret = cfhd_init_vlc(s->table_18_rl_vlc, FF_ARRAY_ELEMS(s->table_18_rl_vlc),
|
||||||
table_18_vlc, FF_ARRAY_ELEMS(table_18_vlc),
|
table_18_vlc, FF_ARRAY_ELEMS(table_18_vlc),
|
||||||
&s->vlc_18, s->avctx);
|
s->avctx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user