[FFmpeg-cvslog] r24621 - trunk/libavcodec/flacenc.c
jbr
subversion
Sat Jul 31 18:46:32 CEST 2010
Author: jbr
Date: Sat Jul 31 18:46:32 2010
New Revision: 24621
Log:
Remove duplicate code by adding a flag for encoding in verbatim mode.
Modified:
trunk/libavcodec/flacenc.c
Modified: trunk/libavcodec/flacenc.c
==============================================================================
--- trunk/libavcodec/flacenc.c Sat Jul 31 18:46:20 2010 (r24620)
+++ trunk/libavcodec/flacenc.c Sat Jul 31 18:46:32 2010 (r24621)
@@ -77,6 +77,7 @@ typedef struct FlacFrame {
int bs_code[2];
uint8_t crc8;
int ch_mode;
+ int verbatim_only;
} FlacFrame;
typedef struct FlacEncodeContext {
@@ -472,6 +473,8 @@ static void init_frame(FlacEncodeContext
for (ch = 0; ch < s->channels; ch++)
frame->subframes[ch].obits = 16;
+
+ frame->verbatim_only = 0;
}
@@ -819,7 +822,7 @@ static int encode_residual_ch(FlacEncode
}
/* VERBATIM */
- if (n < 5) {
+ if (frame->verbatim_only || n < 5) {
sub->type = sub->type_code = FLAC_SUBFRAME_VERBATIM;
encode_residual_verbatim(res, smp, n);
return sub->obits * n;
@@ -985,36 +988,6 @@ static int encode_frame(FlacEncodeContex
}
-static int encode_residual_v(FlacEncodeContext *s, int ch)
-{
- int i, n;
- FlacFrame *frame;
- FlacSubframe *sub;
- int32_t *res, *smp;
-
- frame = &s->frame;
- sub = &frame->subframes[ch];
- res = sub->residual;
- smp = sub->samples;
- n = frame->blocksize;
-
- /* CONSTANT */
- for (i = 1; i < n; i++)
- if (smp[i] != smp[0])
- break;
- if (i == n) {
- sub->type = sub->type_code = FLAC_SUBFRAME_CONSTANT;
- res[0] = smp[0];
- return sub->obits;
- }
-
- /* VERBATIM */
- sub->type = sub->type_code = FLAC_SUBFRAME_VERBATIM;
- encode_residual_verbatim(res, smp, n);
- return sub->obits * n;
-}
-
-
static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n)
{
int i, best;
@@ -1236,7 +1209,6 @@ static void update_md5_sum(FlacEncodeCon
static int flac_encode_frame(AVCodecContext *avctx, uint8_t *frame,
int buf_size, void *data)
{
- int ch;
FlacEncodeContext *s;
const int16_t *samples = data;
int out_bytes;
@@ -1280,8 +1252,8 @@ write_frame:
}
/* frame too large. use verbatim mode */
- for (ch = 0; ch < s->channels; ch++)
- encode_residual_v(s, ch);
+ s->frame.verbatim_only = 1;
+ encode_frame(s);
reencoded = 1;
goto write_frame;
}
More information about the ffmpeg-cvslog
mailing list