diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 999fce7b34..2af9079f37 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -149,7 +149,7 @@ static int decode_unregistered_user_data(H264Context *h, int size){ } user_data[i]= 0; - e= sscanf(user_data+16, "x264 - core %d"/*%s - H.264/MPEG-4 AVC codec - Copyleft 2005 - http://www.videolan.org/x264.html*/, &build); + e = sscanf(user_data + 16, "x264 - core %d", &build); if(e==1 && build>0) h->x264_build= build; if(e==1 && build==1 && !strncmp(user_data+16, "x264 - core 0000", 16)) diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index 7c449f3299..340629c9da 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -32,7 +32,7 @@ #include "sinewin.h" #include "twinvq_data.h" -enum FrameType { +enum TwinVQFrameType { FT_SHORT = 0, ///< Short frame (divided in n sub-blocks) FT_MEDIUM, ///< Medium frame (divided in mmtab; - int size_s = mtab->size / mtab->fmode[FT_SHORT].sub; + const TwinVQModeTab *mtab = tctx->mtab; + int size_s = mtab->size / mtab->fmode[FT_SHORT].sub; for (i = 0; i < size_s / 2; i++) { float cos_i = tctx->cos_tabs[0][i]; @@ -307,14 +307,14 @@ static inline float get_cos(int idx, int part, const float *cos_tab, int size) * (negative cosine values) * @param size the size of the whole output */ -static inline void eval_lpcenv_or_interp(TwinContext *tctx, - enum FrameType ftype, +static inline void eval_lpcenv_or_interp(TwinVQContext *tctx, + enum TwinVQFrameType ftype, float *out, const float *in, int size, int step, int part) { int i; - const ModeTab *mtab = tctx->mtab; - const float *cos_tab = tctx->cos_tabs[ftype]; + const TwinVQModeTab *mtab = tctx->mtab; + const float *cos_tab = tctx->cos_tabs[ftype]; // Fill the 's' for (i = 0; i < size; i += step) @@ -344,7 +344,7 @@ static inline void eval_lpcenv_or_interp(TwinContext *tctx, out[size - 2 * step], step - 1); } -static void eval_lpcenv_2parts(TwinContext *tctx, enum FrameType ftype, +static void eval_lpcenv_2parts(TwinVQContext *tctx, enum TwinVQFrameType ftype, const float *buf, float *lpc, int size, int step) { @@ -363,8 +363,8 @@ static void eval_lpcenv_2parts(TwinContext *tctx, enum FrameType ftype, * bitstream, sum the corresponding vectors and write the result to *out * after permutation. */ -static void dequant(TwinContext *tctx, GetBitContext *gb, float *out, - enum FrameType ftype, +static void dequant(TwinVQContext *tctx, GetBitContext *gb, float *out, + enum TwinVQFrameType ftype, const int16_t *cb0, const int16_t *cb1, int cb_len) { int pos = 0; @@ -478,15 +478,15 @@ static void add_peak(int period, int width, const float *shape, speech[j + center] += ppc_gain * *shape++; } -static void decode_ppc(TwinContext *tctx, int period_coef, const float *shape, - float ppc_gain, float *speech) +static void decode_ppc(TwinVQContext *tctx, int period_coef, + const float *shape, float ppc_gain, float *speech) { - const ModeTab *mtab = tctx->mtab; - int isampf = tctx->avctx->sample_rate / 1000; - int ibps = tctx->avctx->bit_rate / (1000 * tctx->avctx->channels); - int min_period = ROUNDED_DIV(40 * 2 * mtab->size, isampf); - int max_period = ROUNDED_DIV(40 * 2 * mtab->size * 6, isampf); - int period_range = max_period - min_period; + const TwinVQModeTab *mtab = tctx->mtab; + int isampf = tctx->avctx->sample_rate / 1000; + int ibps = tctx->avctx->bit_rate / (1000 * tctx->avctx->channels); + int min_period = ROUNDED_DIV(40 * 2 * mtab->size, isampf); + int max_period = ROUNDED_DIV(40 * 2 * mtab->size * 6, isampf); + int period_range = max_period - min_period; // This is actually the period multiplied by 400. It is just linearly coded // between its maximum and minimum value. @@ -505,10 +505,10 @@ static void decode_ppc(TwinContext *tctx, int period_coef, const float *shape, add_peak(period, width, shape, ppc_gain, speech, mtab->ppc_shape_len); } -static void dec_gain(TwinContext *tctx, GetBitContext *gb, enum FrameType ftype, - float *out) +static void dec_gain(TwinVQContext *tctx, GetBitContext *gb, + enum TwinVQFrameType ftype, float *out) { - const ModeTab *mtab = tctx->mtab; + const TwinVQModeTab *mtab = tctx->mtab; int i, j; int sub = mtab->fmode[ftype].sub; float step = AMP_MAX / ((1 << GAIN_BITS) - 1); @@ -553,10 +553,10 @@ static void rearrange_lsp(int order, float *lsp, float min_dist) } } -static void decode_lsp(TwinContext *tctx, int lpc_idx1, uint8_t *lpc_idx2, +static void decode_lsp(TwinVQContext *tctx, int lpc_idx1, uint8_t *lpc_idx2, int lpc_hist_idx, float *lsp, float *hist) { - const ModeTab *mtab = tctx->mtab; + const TwinVQModeTab *mtab = tctx->mtab; int i, j; const float *cb = mtab->lspcodebook; @@ -593,8 +593,8 @@ static void decode_lsp(TwinContext *tctx, int lpc_idx1, uint8_t *lpc_idx2, ff_sort_nearly_sorted_floats(lsp, mtab->n_lsp); } -static void dec_lpc_spectrum_inv(TwinContext *tctx, float *lsp, - enum FrameType ftype, float *lpc) +static void dec_lpc_spectrum_inv(TwinVQContext *tctx, float *lsp, + enum TwinVQFrameType ftype, float *lpc) { int i; int size = tctx->mtab->size / tctx->mtab->fmode[ftype].sub; @@ -617,14 +617,14 @@ static void dec_lpc_spectrum_inv(TwinContext *tctx, float *lsp, static const uint8_t wtype_to_wsize[] = { 0, 0, 2, 2, 2, 1, 0, 1, 1 }; -static void imdct_and_window(TwinContext *tctx, enum FrameType ftype, int wtype, - float *in, float *prev, int ch) +static void imdct_and_window(TwinVQContext *tctx, enum TwinVQFrameType ftype, + int wtype, float *in, float *prev, int ch) { - FFTContext *mdct = &tctx->mdct_ctx[ftype]; - const ModeTab *mtab = tctx->mtab; - int bsize = mtab->size / mtab->fmode[ftype].sub; - int size = mtab->size; - float *buf1 = tctx->tmp_buf; + FFTContext *mdct = &tctx->mdct_ctx[ftype]; + const TwinVQModeTab *mtab = tctx->mtab; + int bsize = mtab->size / mtab->fmode[ftype].sub; + int size = mtab->size; + float *buf1 = tctx->tmp_buf; int j, first_wsize, wsize; // Window size float *out = tctx->curr_frame + 2 * ch * mtab->size; float *out2 = out; @@ -668,11 +668,11 @@ static void imdct_and_window(TwinContext *tctx, enum FrameType ftype, int wtype, tctx->last_block_pos[ch] = (size + first_wsize) / 2; } -static void imdct_output(TwinContext *tctx, enum FrameType ftype, int wtype, - float **out) +static void imdct_output(TwinVQContext *tctx, enum TwinVQFrameType ftype, + int wtype, float **out) { - const ModeTab *mtab = tctx->mtab; - float *prev_buf = tctx->prev_frame + tctx->last_block_pos[0]; + const TwinVQModeTab *mtab = tctx->mtab; + float *prev_buf = tctx->prev_frame + tctx->last_block_pos[0]; int size1, size2, i; for (i = 0; i < tctx->avctx->channels; i++) @@ -699,10 +699,11 @@ static void imdct_output(TwinContext *tctx, enum FrameType ftype, int wtype, } } -static void dec_bark_env(TwinContext *tctx, const uint8_t *in, int use_hist, - int ch, float *out, float gain, enum FrameType ftype) +static void dec_bark_env(TwinVQContext *tctx, const uint8_t *in, int use_hist, + int ch, float *out, float gain, + enum TwinVQFrameType ftype) { - const ModeTab *mtab = tctx->mtab; + const TwinVQModeTab *mtab = tctx->mtab; int i, j; float *hist = tctx->bark_hist[ftype][ch]; float val = ((const float []) { 0.4, 0.35, 0.28 })[ftype]; @@ -726,13 +727,13 @@ static void dec_bark_env(TwinContext *tctx, const uint8_t *in, int use_hist, } } -static void read_and_decode_spectrum(TwinContext *tctx, GetBitContext *gb, - float *out, enum FrameType ftype) +static void read_and_decode_spectrum(TwinVQContext *tctx, GetBitContext *gb, + float *out, enum TwinVQFrameType ftype) { - const ModeTab *mtab = tctx->mtab; - int channels = tctx->avctx->channels; - int sub = mtab->fmode[ftype].sub; - int block_size = mtab->size / sub; + const TwinVQModeTab *mtab = tctx->mtab; + int channels = tctx->avctx->channels; + int sub = mtab->fmode[ftype].sub; + int block_size = mtab->size / sub; float gain[CHANNELS_MAX * SUBBLOCKS_MAX]; float ppc_shape[PPC_SHAPE_LEN_MAX * CHANNELS_MAX * 4]; uint8_t bark1[CHANNELS_MAX][SUBBLOCKS_MAX][BARK_N_COEF_MAX]; @@ -812,19 +813,19 @@ static void read_and_decode_spectrum(TwinContext *tctx, GetBitContext *gb, } } -static int twin_decode_frame(AVCodecContext *avctx, void *data, - int *got_frame_ptr, AVPacket *avpkt) +static int twinvq_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame_ptr, AVPacket *avpkt) { AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - TwinContext *tctx = avctx->priv_data; + TwinVQContext *tctx = avctx->priv_data; GetBitContext gb; - const ModeTab *mtab = tctx->mtab; - float **out = NULL; - enum FrameType ftype; + const TwinVQModeTab *mtab = tctx->mtab; + float **out = NULL; + enum TwinVQFrameType ftype; int window_type, ret; - static const enum FrameType wtype_to_ftype_table[] = { + static const enum TwinVQFrameType wtype_to_ftype_table[] = { FT_LONG, FT_LONG, FT_SHORT, FT_LONG, FT_MEDIUM, FT_LONG, FT_LONG, FT_MEDIUM, FT_MEDIUM }; @@ -874,14 +875,14 @@ static int twin_decode_frame(AVCodecContext *avctx, void *data, /** * Init IMDCT and windowing tables */ -static av_cold int init_mdct_win(TwinContext *tctx) +static av_cold int init_mdct_win(TwinVQContext *tctx) { int i, j, ret; - const ModeTab *mtab = tctx->mtab; - int size_s = mtab->size / mtab->fmode[FT_SHORT].sub; - int size_m = mtab->size / mtab->fmode[FT_MEDIUM].sub; - int channels = tctx->avctx->channels; - float norm = channels == 1 ? 2.0 : 1.0; + const TwinVQModeTab *mtab = tctx->mtab; + int size_s = mtab->size / mtab->fmode[FT_SHORT].sub; + int size_m = mtab->size / mtab->fmode[FT_MEDIUM].sub; + int channels = tctx->avctx->channels; + float norm = channels == 1 ? 2.0 : 1.0; for (i = 0; i < 3; i++) { int bsize = tctx->mtab->size / tctx->mtab->fmode[i].sub; @@ -934,7 +935,7 @@ alloc_fail: static void permutate_in_line(int16_t *tab, int num_vect, int num_blocks, int block_size, const uint8_t line_len[2], int length_div, - enum FrameType ftype) + enum TwinVQFrameType ftype) { int i, j; @@ -991,11 +992,11 @@ static void linear_perm(int16_t *out, int16_t *in, int n_blocks, int size) out[i] = block_size * (in[i] % n_blocks) + in[i] / n_blocks; } -static av_cold void construct_perm_table(TwinContext *tctx, - enum FrameType ftype) +static av_cold void construct_perm_table(TwinVQContext *tctx, + enum TwinVQFrameType ftype) { int block_size, size; - const ModeTab *mtab = tctx->mtab; + const TwinVQModeTab *mtab = tctx->mtab; int16_t *tmp_perm = (int16_t *)tctx->tmp_buf; if (ftype == FT_PPC) { @@ -1017,12 +1018,12 @@ static av_cold void construct_perm_table(TwinContext *tctx, size * block_size); } -static av_cold void init_bitstream_params(TwinContext *tctx) +static av_cold void init_bitstream_params(TwinVQContext *tctx) { - const ModeTab *mtab = tctx->mtab; - int n_ch = tctx->avctx->channels; - int total_fr_bits = tctx->avctx->bit_rate * mtab->size / - tctx->avctx->sample_rate; + const TwinVQModeTab *mtab = tctx->mtab; + int n_ch = tctx->avctx->channels; + int total_fr_bits = tctx->avctx->bit_rate * mtab->size / + tctx->avctx->sample_rate; int lsp_bits_per_block = n_ch * (mtab->lsp_bit0 + mtab->lsp_bit1 + mtab->lsp_split * mtab->lsp_bit2); @@ -1031,7 +1032,7 @@ static av_cold void init_bitstream_params(TwinContext *tctx) mtab->ppc_period_bit); int bsize_no_main_cb[3], bse_bits[3], i; - enum FrameType frametype; + enum TwinVQFrameType frametype; for (i = 0; i < 3; i++) // +1 for history usage switch @@ -1086,9 +1087,9 @@ static av_cold void init_bitstream_params(TwinContext *tctx) construct_perm_table(tctx, frametype); } -static av_cold int twin_decode_close(AVCodecContext *avctx) +static av_cold int twinvq_decode_close(AVCodecContext *avctx) { - TwinContext *tctx = avctx->priv_data; + TwinVQContext *tctx = avctx->priv_data; int i; for (i = 0; i < 3; i++) { @@ -1104,10 +1105,10 @@ static av_cold int twin_decode_close(AVCodecContext *avctx) return 0; } -static av_cold int twin_decode_init(AVCodecContext *avctx) +static av_cold int twinvq_decode_init(AVCodecContext *avctx) { int ret, isampf, ibps; - TwinContext *tctx = avctx->priv_data; + TwinVQContext *tctx = avctx->priv_data; tctx->avctx = avctx; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; @@ -1192,7 +1193,7 @@ static av_cold int twin_decode_init(AVCodecContext *avctx) avpriv_float_dsp_init(&tctx->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); if ((ret = init_mdct_win(tctx))) { av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n"); - twin_decode_close(avctx); + twinvq_decode_close(avctx); return ret; } init_bitstream_params(tctx); @@ -1206,10 +1207,10 @@ AVCodec ff_twinvq_decoder = { .name = "twinvq", .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_TWINVQ, - .priv_data_size = sizeof(TwinContext), - .init = twin_decode_init, - .close = twin_decode_close, - .decode = twin_decode_frame, + .priv_data_size = sizeof(TwinVQContext), + .init = twinvq_decode_init, + .close = twinvq_decode_close, + .decode = twinvq_decode_frame, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"), .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,