cosmetics: indentation, prettyprinting, K&R coding style

Originally committed as revision 19652 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Diego Biurrun 2009-08-15 11:42:15 +00:00
parent c64380009d
commit 0ebe3b8e2b
8 changed files with 267 additions and 304 deletions

View File

@ -53,8 +53,7 @@ unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext)
sizeof(ff_dirac_schro_video_format_info[0]);
for (idx = 1; idx < num_formats; ++idx) {
const FfmpegDiracSchroVideoFormatInfo *vf =
&ff_dirac_schro_video_format_info[idx];
const FfmpegDiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx];
if (avccontext->width == vf->width &&
avccontext->height == vf->height) {
ret_idx = idx;
@ -81,8 +80,7 @@ void ff_dirac_schro_queue_free (FfmpegDiracSchroQueue *queue,
int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data)
{
FfmpegDiracSchroQueueElement *p_new =
av_mallocz(sizeof(FfmpegDiracSchroQueueElement));
FfmpegDiracSchroQueueElement *p_new = av_mallocz(sizeof(FfmpegDiracSchroQueueElement));
if (!p_new)
return -1;

View File

@ -28,8 +28,7 @@
#include "avcodec.h"
typedef struct
{
typedef struct {
uint16_t width;
uint16_t height;
uint16_t frame_rate_num;
@ -44,8 +43,7 @@ unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext);
/**
* contains a single encoded frame returned from Dirac or Schroedinger
*/
typedef struct FfmpegDiracSchroEncodedFrame
{
typedef struct FfmpegDiracSchroEncodedFrame {
/** encoded frame data */
uint8_t *p_encbuf;
@ -62,8 +60,7 @@ typedef struct FfmpegDiracSchroEncodedFrame
/**
* queue element
*/
typedef struct FfmpegDiracSchroQueueElement
{
typedef struct FfmpegDiracSchroQueueElement {
/** Data to be stored in queue*/
void *data;
/** Pointer to next element queue */
@ -74,8 +71,7 @@ typedef struct FfmpegDiracSchroQueueElement
/**
* A simple queue implementation used in libdirac and libschroedinger
*/
typedef struct FfmpegDiracSchroQueue
{
typedef struct FfmpegDiracSchroQueue {
/** Pointer to head of queue */
FfmpegDiracSchroQueueElement *p_head;
/** Pointer to tail of queue */

View File

@ -36,8 +36,7 @@
#include <libdirac_decoder/dirac_parser.h>
/** contains a single frame returned from Dirac */
typedef struct FfmpegDiracDecoderParams
{
typedef struct FfmpegDiracDecoderParams {
/** decoder handle */
dirac_decoder_t* p_decoder;
@ -97,16 +96,14 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
while (1) {
/* parse data and process result */
DecoderState state = dirac_parse(p_dirac_params->p_decoder);
switch (state)
{
switch (state) {
case STATE_BUFFER:
return buf_size;
case STATE_SEQUENCE:
{
/* tell FFmpeg about sequence details */
dirac_sourceparams_t *src_params =
&p_dirac_params->p_decoder->src_params;
dirac_sourceparams_t *src_params = &p_dirac_params->p_decoder->src_params;
if (avcodec_check_dimensions(avccontext, src_params->width,
src_params->height) < 0) {

View File

@ -38,8 +38,7 @@
#include <libdirac_encoder/dirac_encoder.h>
/** Dirac encoder private data */
typedef struct FfmpegDiracEncoderParams
{
typedef struct FfmpegDiracEncoderParams {
/** Dirac encoder context */
dirac_encoder_context_t enc_ctx;
@ -139,8 +138,7 @@ static av_cold int libdirac_encode_init(AVCodecContext *avccontext)
/* initialize the encoder context */
dirac_encoder_context_init(&(p_dirac_params->enc_ctx), preset);
p_dirac_params->enc_ctx.src_params.chroma =
GetDiracChromaFormat(avccontext->pix_fmt);
p_dirac_params->enc_ctx.src_params.chroma = GetDiracChromaFormat(avccontext->pix_fmt);
if (p_dirac_params->enc_ctx.src_params.chroma == formatNK) {
av_log(avccontext, AV_LOG_ERROR,
@ -150,10 +148,8 @@ static av_cold int libdirac_encode_init(AVCodecContext *avccontext)
return -1;
}
p_dirac_params->enc_ctx.src_params.frame_rate.numerator =
avccontext->time_base.den;
p_dirac_params->enc_ctx.src_params.frame_rate.denominator =
avccontext->time_base.num;
p_dirac_params->enc_ctx.src_params.frame_rate.numerator = avccontext->time_base.den;
p_dirac_params->enc_ctx.src_params.frame_rate.denominator = avccontext->time_base.num;
p_dirac_params->enc_ctx.src_params.width = avccontext->width;
p_dirac_params->enc_ctx.src_params.height = avccontext->height;
@ -182,13 +178,13 @@ static av_cold int libdirac_encode_init(AVCodecContext *avccontext)
if (avccontext->flags & CODEC_FLAG_QSCALE) {
if (avccontext->global_quality) {
p_dirac_params->enc_ctx.enc_params.qf =
avccontext->global_quality / (FF_QP2LAMBDA*10.0);
p_dirac_params->enc_ctx.enc_params.qf = avccontext->global_quality
/ (FF_QP2LAMBDA * 10.0);
/* if it is not default bitrate then send target rate. */
if (avccontext->bit_rate >= 1000 &&
avccontext->bit_rate != 200000)
p_dirac_params->enc_ctx.enc_params.trate =
avccontext->bit_rate / 1000;
p_dirac_params->enc_ctx.enc_params.trate = avccontext->bit_rate
/ 1000;
} else
p_dirac_params->enc_ctx.enc_params.lossless = 1;
} else if (avccontext->bit_rate >= 1000)
@ -277,8 +273,7 @@ static int libdirac_encode_frame(AVCodecContext *avccontext,
/* process frame */
state = dirac_encoder_output(p_dirac_params->p_encoder);
switch (state)
{
switch (state) {
case ENC_STATE_AVAIL:
case ENC_STATE_EOS:
assert(p_dirac_params->p_encoder->enc_buf.size > 0);
@ -288,17 +283,14 @@ static int libdirac_encode_frame(AVCodecContext *avccontext,
* to the frame output queue until we actually have a frame
*/
p_dirac_params->enc_buf = av_realloc (
p_dirac_params->enc_buf,
p_dirac_params->enc_buf = av_realloc(p_dirac_params->enc_buf,
p_dirac_params->enc_buf_size +
p_dirac_params->p_encoder->enc_buf.size
);
p_dirac_params->p_encoder->enc_buf.size);
memcpy(p_dirac_params->enc_buf + p_dirac_params->enc_buf_size,
p_dirac_params->p_encoder->enc_buf.buffer,
p_dirac_params->p_encoder->enc_buf.size);
p_dirac_params->enc_buf_size +=
p_dirac_params->p_encoder->enc_buf.size;
p_dirac_params->enc_buf_size += p_dirac_params->p_encoder->enc_buf.size;
if (state == ENC_STATE_EOS) {
p_dirac_params->eos_pulled = 1;
@ -315,8 +307,7 @@ static int libdirac_encode_frame(AVCodecContext *avccontext,
/* set output data */
p_frame_output->size = p_dirac_params->enc_buf_size;
p_frame_output->p_encbuf = p_dirac_params->enc_buf;
p_frame_output->frame_num =
p_dirac_params->p_encoder->enc_pparams.pnum;
p_frame_output->frame_num = p_dirac_params->p_encoder->enc_pparams.pnum;
if (p_dirac_params->p_encoder->enc_pparams.ptype == INTRA_PICTURE &&
p_dirac_params->p_encoder->enc_pparams.rtype == REFERENCE_PICTURE)
@ -346,12 +337,10 @@ static int libdirac_encode_frame(AVCodecContext *avccontext,
/* copy 'next' frame in queue */
if (p_dirac_params->enc_frame_queue.size == 1 &&
p_dirac_params->eos_pulled)
if (p_dirac_params->enc_frame_queue.size == 1 && p_dirac_params->eos_pulled)
last_frame_in_sequence = 1;
p_next_output_frame =
ff_dirac_schro_queue_pop(&p_dirac_params->enc_frame_queue);
p_next_output_frame = ff_dirac_schro_queue_pop(&p_dirac_params->enc_frame_queue);
if (!p_next_output_frame)
return 0;
@ -366,8 +355,7 @@ static int libdirac_encode_frame(AVCodecContext *avccontext,
/* Append the end of sequence information to the last frame in the
* sequence. */
if (last_frame_in_sequence && p_dirac_params->enc_buf_size > 0)
{
if (last_frame_in_sequence && p_dirac_params->enc_buf_size > 0) {
memcpy(frame + enc_size, p_dirac_params->enc_buf,
p_dirac_params->enc_buf_size);
enc_size += p_dirac_params->enc_buf_size;

View File

@ -57,8 +57,8 @@ SchroVideoFormatEnum ff_get_schro_video_format_preset(AVCodecContext *avccontext
unsigned int idx = ff_dirac_schro_get_video_format_idx (avccontext);
return (idx < num_formats) ?
ff_schro_video_formats[idx] : SCHRO_VIDEO_FORMAT_CUSTOM;
return (idx < num_formats) ? ff_schro_video_formats[idx] :
SCHRO_VIDEO_FORMAT_CUSTOM;
}
int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt,
@ -71,8 +71,7 @@ int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt,
for (idx = 0; idx < num_formats; ++idx) {
if (ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) {
*schro_frame_fmt =
ffmpeg_schro_pixel_format_map[idx].schro_frame_fmt;
*schro_frame_fmt = ffmpeg_schro_pixel_format_map[idx].schro_frame_fmt;
return 0;
}
}

View File

@ -40,8 +40,7 @@
#include <schroedinger/schrovideoformat.h>
/** libschroedinger decoder private data */
typedef struct FfmpegSchroDecoderParams
{
typedef struct FfmpegSchroDecoderParams {
/** Schroedinger video format */
SchroVideoFormat *format;
@ -64,8 +63,7 @@ typedef struct FfmpegSchroDecoderParams
AVPicture dec_pic;
} FfmpegSchroDecoderParams;
typedef struct FfmpegSchroParseUnitContext
{
typedef struct FfmpegSchroParseUnitContext {
const uint8_t *buf;
int buf_size;
} FfmpegSchroParseUnitContext;
@ -180,8 +178,7 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext)
}
avccontext->height = p_schro_params->format->height;
avccontext->width = p_schro_params->format->width;
avccontext->pix_fmt =
GetFfmpegChromaFormat(p_schro_params->format->chroma_format);
avccontext->pix_fmt = GetFfmpegChromaFormat(p_schro_params->format->chroma_format);
if (ff_get_schro_frame_format(p_schro_params->format->chroma_format,
&p_schro_params->frame_format) == -1) {
@ -240,16 +237,14 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
libschroedinger_handle_first_access_unit(avccontext);
go = 1;
}
else
} else
outer = 0;
format = p_schro_params->format;
while (go) {
/* Parse data and process result. */
state = schro_decoder_wait(decoder);
switch (state)
{
switch (state) {
case SCHRO_DECODER_FIRST_ACCESS_UNIT:
libschroedinger_handle_first_access_unit(avccontext);
break;
@ -274,8 +269,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
frame = schro_decoder_pull(decoder);
if (frame)
ff_dirac_schro_queue_push_back(
&p_schro_params->dec_frame_queue,
ff_dirac_schro_queue_push_back(&p_schro_params->dec_frame_queue,
frame);
break;
case SCHRO_DECODER_EOS:

View File

@ -40,8 +40,7 @@
/** libschroedinger encoder private data */
typedef struct FfmpegSchroEncoderParams
{
typedef struct FfmpegSchroEncoderParams {
/** Schroedinger video format */
SchroVideoFormat *format;
@ -153,8 +152,7 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext)
if (avccontext->coder_type == FF_CODER_TYPE_VLC)
schro_encoder_setting_set_double(p_schro_params->encoder,
"enable_noarith", 1);
}
else {
} else {
schro_encoder_setting_set_double(p_schro_params->encoder,
"gop_structure",
SCHRO_ENCODER_GOP_BIREF);
@ -181,8 +179,7 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext)
"noise_threshold",
noise_threshold);
}
}
else {
} else {
schro_encoder_setting_set_double(p_schro_params->encoder,
"rate_control",
SCHRO_ENCODER_RATE_CONTROL_CONSTANT_BITRATE);
@ -282,12 +279,10 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext,
while (go) {
SchroStateEnum state;
state = schro_encoder_wait(encoder);
switch (state)
{
switch (state) {
case SCHRO_STATE_HAVE_BUFFER:
case SCHRO_STATE_END_OF_STREAM:
enc_buf = schro_encoder_pull (encoder,
&presentation_frame);
enc_buf = schro_encoder_pull(encoder, &presentation_frame);
assert(enc_buf->length > 0);
assert(enc_buf->length <= buf_size);
parse_code = enc_buf->data[4];
@ -296,10 +291,8 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext,
* be able to set the pts correctly. So we don't write data
* to the frame output queue until we actually have a frame
*/
p_schro_params->enc_buf = av_realloc (
p_schro_params->enc_buf,
p_schro_params->enc_buf_size + enc_buf->length
);
p_schro_params->enc_buf = av_realloc(p_schro_params->enc_buf,
p_schro_params->enc_buf_size + enc_buf->length);
memcpy(p_schro_params->enc_buf + p_schro_params->enc_buf_size,
enc_buf->data, enc_buf->length);
@ -360,8 +353,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext,
p_schro_params->eos_pulled)
last_frame_in_sequence = 1;
p_frame_output =
ff_dirac_schro_queue_pop (&p_schro_params->enc_frame_queue);
p_frame_output = ff_dirac_schro_queue_pop(&p_schro_params->enc_frame_queue);
if (!p_frame_output)
return 0;
@ -376,8 +368,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext,
/* Append the end of sequence information to the last frame in the
* sequence. */
if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0)
{
if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0) {
memcpy(frame + enc_size, p_schro_params->enc_buf,
p_schro_params->enc_buf_size);
enc_size += p_schro_params->enc_buf_size;