cosmetics: K&R coding style, prettyprinting

backported r20083 by diego

This commit does not introduce functional changes.  It was applied in
order to faciliate reviewing the proposed libx264.c backport



Originally committed as revision 21832 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5
This commit is contained in:
Reinhard Tartler
2010-02-15 12:45:14 +00:00
parent 9593c80062
commit 26f74e832b

View File

@@ -33,8 +33,7 @@ typedef struct X264Context {
AVFrame out_pic; AVFrame out_pic;
} X264Context; } X264Context;
static void static void X264_log(void *p, int level, const char *fmt, va_list args)
X264_log(void *p, int level, const char *fmt, va_list args)
{ {
static const int level_map[] = { static const int level_map[] = {
[X264_LOG_ERROR] = AV_LOG_ERROR, [X264_LOG_ERROR] = AV_LOG_ERROR,
@@ -50,8 +49,7 @@ X264_log(void *p, int level, const char *fmt, va_list args)
} }
static int static int encode_nals(uint8_t *buf, int size, x264_nal_t *nals, int nnal)
encode_nals(uint8_t *buf, int size, x264_nal_t *nals, int nnal)
{ {
uint8_t *p = buf; uint8_t *p = buf;
int i; int i;
@@ -66,8 +64,8 @@ encode_nals(uint8_t *buf, int size, x264_nal_t *nals, int nnal)
return p - buf; return p - buf;
} }
static int static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
X264_frame(AVCodecContext *ctx, uint8_t *buf, int bufsize, void *data) int bufsize, void *data)
{ {
X264Context *x4 = ctx->priv_data; X264Context *x4 = ctx->priv_data;
AVFrame *frame = data; AVFrame *frame = data;
@@ -119,8 +117,7 @@ X264_frame(AVCodecContext *ctx, uint8_t *buf, int bufsize, void *data)
return bufsize; return bufsize;
} }
static av_cold int static av_cold int X264_close(AVCodecContext *avctx)
X264_close(AVCodecContext *avctx)
{ {
X264Context *x4 = avctx->priv_data; X264Context *x4 = avctx->priv_data;
@@ -132,8 +129,7 @@ X264_close(AVCodecContext *avctx)
return 0; return 0;
} }
static av_cold int static av_cold int X264_init(AVCodecContext *avctx)
X264_init(AVCodecContext *avctx)
{ {
X264Context *x4 = avctx->priv_data; X264Context *x4 = avctx->priv_data;
@@ -147,8 +143,9 @@ X264_init(AVCodecContext *avctx)
x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000; x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000; x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1; x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1;
if(avctx->flags & CODEC_FLAG_PASS2) x4->params.rc.b_stat_read = 1; if (avctx->flags & CODEC_FLAG_PASS2) {
else{ x4->params.rc.b_stat_read = 1;
} else {
if (avctx->crf) { if (avctx->crf) {
x4->params.rc.i_rc_method = X264_RC_CRF; x4->params.rc.i_rc_method = X264_RC_CRF;
x4->params.rc.f_rf_constant = avctx->crf; x4->params.rc.f_rf_constant = avctx->crf;
@@ -160,7 +157,8 @@ X264_init(AVCodecContext *avctx)
// if neither crf nor cqp modes are selected we have to enable the RC // if neither crf nor cqp modes are selected we have to enable the RC
// we do it this way because we cannot check if the bitrate has been set // we do it this way because we cannot check if the bitrate has been set
if(!(avctx->crf || (avctx->cqp > -1))) x4->params.rc.i_rc_method = X264_RC_ABR; if (!(avctx->crf || (avctx->cqp > -1)))
x4->params.rc.i_rc_method = X264_RC_ABR;
x4->params.i_bframe = avctx->max_b_frames; x4->params.i_bframe = avctx->max_b_frames;
x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC; x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
@@ -229,8 +227,7 @@ X264_init(AVCodecContext *avctx)
x4->params.analyse.i_me_range = avctx->me_range; x4->params.analyse.i_me_range = avctx->me_range;
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
x4->params.analyse.b_mixed_references = x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS;
avctx->flags2 & CODEC_FLAG2_MIXED_REFS;
x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA; x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT; x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT;
x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP; x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP;
@@ -238,7 +235,8 @@ X264_init(AVCodecContext *avctx)
x4->params.analyse.i_trellis = avctx->trellis; x4->params.analyse.i_trellis = avctx->trellis;
x4->params.analyse.i_noise_reduction = avctx->noise_reduction; x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
if(avctx->level > 0) x4->params.i_level_idc = avctx->level; if (avctx->level > 0)
x4->params.i_level_idc = avctx->level;
x4->params.rc.f_rate_tolerance = x4->params.rc.f_rate_tolerance =
(float)avctx->bit_rate_tolerance/avctx->bit_rate; (float)avctx->bit_rate_tolerance/avctx->bit_rate;
@@ -247,8 +245,8 @@ X264_init(AVCodecContext *avctx)
(avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) { (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) {
x4->params.rc.f_vbv_buffer_init = x4->params.rc.f_vbv_buffer_init =
(float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size; (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size;
} } else
else x4->params.rc.f_vbv_buffer_init = 0.9; x4->params.rc.f_vbv_buffer_init = 0.9;
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor); x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor; x4->params.rc.f_pb_factor = avctx->b_quant_factor;
@@ -263,9 +261,8 @@ X264_init(AVCodecContext *avctx)
x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT; x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){ if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
x4->params.b_repeat_headers = 0; x4->params.b_repeat_headers = 0;
}
x4->enc = x264_encoder_open(&x4->params); x4->enc = x264_encoder_open(&x4->params);
if (!x4->enc) if (!x4->enc)