Commit 9a2c23de authored by diego's avatar diego

cosmetics: indentation, prettyprinting, K&R coding style


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@19652 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 0f9cdb79
......@@ -45,18 +45,17 @@ static const FfmpegDiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[]
{ 4096, 2160, 24, 1 },
};
unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext)
unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext)
{
unsigned int ret_idx = 0;
unsigned int idx;
unsigned int num_formats = sizeof(ff_dirac_schro_video_format_info) /
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];
for (idx = 1; idx < num_formats; ++idx) {
const FfmpegDiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx];
if (avccontext->width == vf->width &&
avccontext->height == vf->height){
avccontext->height == vf->height) {
ret_idx = idx;
if (avccontext->time_base.den == vf->frame_rate_num &&
avccontext->time_base.num == vf->frame_rate_denom)
......@@ -66,23 +65,22 @@ unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext)
return ret_idx;
}
void ff_dirac_schro_queue_init (FfmpegDiracSchroQueue *queue)
void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue)
{
queue->p_head = queue->p_tail = NULL;
queue->size = 0;
}
void ff_dirac_schro_queue_free (FfmpegDiracSchroQueue *queue,
void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue,
void (*free_func)(void *))
{
while (queue->p_head)
free_func( ff_dirac_schro_queue_pop(queue) );
free_func(ff_dirac_schro_queue_pop(queue));
}
int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data)
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;
......@@ -99,7 +97,7 @@ int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data)
return 0;
}
void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue)
void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue)
{
FfmpegDiracSchroQueueElement *top = queue->p_head;
......@@ -107,7 +105,7 @@ void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue)
void *data = top->data;
queue->p_head = queue->p_head->next;
--queue->size;
av_freep (&top);
av_freep(&top);
return data;
}
......
......@@ -28,8 +28,7 @@
#include "avcodec.h"
typedef struct
{
typedef struct {
uint16_t width;
uint16_t height;
uint16_t frame_rate_num;
......@@ -39,13 +38,12 @@ typedef struct
/**
* Returns the index into the Dirac Schro common video format info table
*/
unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext);
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 */
......@@ -92,12 +88,12 @@ void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue);
/**
* Add an element to the end of the queue
*/
int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data);
int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data);
/**
* Return the first element in the queue
*/
void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue);
void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue);
/**
* Free the queue resources. free_func is a function supplied by the caller to
......
......@@ -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;
......@@ -64,13 +63,13 @@ static enum PixelFormat GetFfmpegChromaFormat(dirac_chroma_t dirac_pix_fmt)
static av_cold int libdirac_decode_init(AVCodecContext *avccontext)
{
FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data ;
FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data;
p_dirac_params->p_decoder = dirac_decoder_init(avccontext->debug);
if (!p_dirac_params->p_decoder)
return -1;
return 0 ;
return 0;
}
static int libdirac_decode_frame(AVCodecContext *avccontext,
......@@ -88,25 +87,23 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
*data_size = 0;
if (buf_size>0) {
if (buf_size > 0) {
/* set data to decode into buffer */
dirac_buffer (p_dirac_params->p_decoder, buf, buf+buf_size);
if ((buf[4] &0x08) == 0x08 && (buf[4] & 0x03))
dirac_buffer(p_dirac_params->p_decoder, buf, buf + buf_size);
if ((buf[4] & 0x08) == 0x08 && (buf[4] & 0x03))
avccontext->has_b_frames = 1;
}
while (1) {
/* parse data and process result */
DecoderState state = dirac_parse (p_dirac_params->p_decoder);
switch (state)
{
DecoderState state = dirac_parse(p_dirac_params->p_decoder);
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) {
......@@ -121,7 +118,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
avccontext->pix_fmt = GetFfmpegChromaFormat(src_params->chroma);
if (avccontext->pix_fmt == PIX_FMT_NONE) {
av_log (avccontext, AV_LOG_ERROR,
av_log(avccontext, AV_LOG_ERROR,
"Dirac chroma format %d not supported currently\n",
src_params->chroma);
return -1;
......@@ -140,7 +137,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
/* allocate output buffer */
if (!p_dirac_params->p_out_frame_buf)
p_dirac_params->p_out_frame_buf = av_malloc (pict_size);
p_dirac_params->p_out_frame_buf = av_malloc(pict_size);
buffer[0] = p_dirac_params->p_out_frame_buf;
buffer[1] = p_dirac_params->p_out_frame_buf +
pic.linesize[0] * avccontext->height;
......@@ -177,20 +174,20 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
static av_cold int libdirac_decode_close(AVCodecContext *avccontext)
{
FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data;
dirac_decoder_close (p_dirac_params->p_decoder);
dirac_decoder_close(p_dirac_params->p_decoder);
av_freep(&p_dirac_params->p_out_frame_buf);
return 0 ;
return 0;
}
static void libdirac_flush (AVCodecContext *avccontext)
static void libdirac_flush(AVCodecContext *avccontext)
{
/* Got a seek request. We will need free memory held in the private
* context and free the current Dirac decoder handle and then open
* a new decoder handle. */
libdirac_decode_close (avccontext);
libdirac_decode_init (avccontext);
libdirac_decode_close(avccontext);
libdirac_decode_init(avccontext);
return;
}
......@@ -208,4 +205,4 @@ AVCodec libdirac_decoder = {
CODEC_CAP_DELAY,
.flush = libdirac_flush,
.long_name = NULL_IF_CONFIG_SMALL("libdirac Dirac 2.2"),
} ;
};
This diff is collapsed.
......@@ -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;
}
}
......
......@@ -50,7 +50,7 @@ SchroVideoFormatEnum ff_get_schro_video_format_preset (AVCodecContext *avccontex
* Sets the Schroedinger frame format corresponding to the Schro chroma format
* passed. Returns 0 on success, -1 on failure.
*/
int ff_get_schro_frame_format (SchroChromaFormat schro_chroma_fmt,
int ff_get_schro_frame_format(SchroChromaFormat schro_chroma_fmt,
SchroFrameFormat *schro_frame_fmt);
#endif /* AVCODEC_LIBSCHROEDINGER_H */
......@@ -40,8 +40,7 @@
#include <schroedinger/schrovideoformat.h>
/** libschroedinger decoder private data */
typedef struct FfmpegSchroDecoderParams
{
typedef struct FfmpegSchroDecoderParams {
/** Schroedinger video format */
SchroVideoFormat *format;
......@@ -64,24 +63,23 @@ typedef struct FfmpegSchroDecoderParams
AVPicture dec_pic;
} FfmpegSchroDecoderParams;
typedef struct FfmpegSchroParseUnitContext
{
typedef struct FfmpegSchroParseUnitContext {
const uint8_t *buf;
int buf_size;
} FfmpegSchroParseUnitContext;
static void libschroedinger_decode_buffer_free (SchroBuffer *schro_buf,
static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf,
void *priv);
static void FfmpegSchroParseContextInit (FfmpegSchroParseUnitContext *parse_ctx,
static void FfmpegSchroParseContextInit(FfmpegSchroParseUnitContext *parse_ctx,
const uint8_t *buf, int buf_size)
{
parse_ctx->buf = buf;
parse_ctx->buf_size = buf_size;
}
static SchroBuffer* FfmpegFindNextSchroParseUnit (FfmpegSchroParseUnitContext *parse_ctx)
static SchroBuffer* FfmpegFindNextSchroParseUnit(FfmpegSchroParseUnitContext *parse_ctx)
{
SchroBuffer *enc_buf = NULL;
int next_pu_offset = 0;
......@@ -107,8 +105,8 @@ static SchroBuffer* FfmpegFindNextSchroParseUnit (FfmpegSchroParseUnitContext *p
return NULL;
in_buf = av_malloc(next_pu_offset);
memcpy (in_buf, parse_ctx->buf, next_pu_offset);
enc_buf = schro_buffer_new_with_data (in_buf, next_pu_offset);
memcpy(in_buf, parse_ctx->buf, next_pu_offset);
enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);
enc_buf->free = libschroedinger_decode_buffer_free;
enc_buf->priv = in_buf;
......@@ -136,7 +134,7 @@ static enum PixelFormat GetFfmpegChromaFormat(SchroChromaFormat schro_pix_fmt)
static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext)
{
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data ;
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
/* First of all, initialize our supporting libraries. */
schro_init();
......@@ -148,17 +146,17 @@ static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext)
return -1;
/* Initialize the decoded frame queue. */
ff_dirac_schro_queue_init (&p_schro_params->dec_frame_queue);
return 0 ;
ff_dirac_schro_queue_init(&p_schro_params->dec_frame_queue);
return 0;
}
static void libschroedinger_decode_buffer_free (SchroBuffer *schro_buf,
static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf,
void *priv)
{
av_freep(&priv);
}
static void libschroedinger_decode_frame_free (void *frame)
static void libschroedinger_decode_frame_free(void *frame)
{
schro_frame_unref(frame);
}
......@@ -168,10 +166,10 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext)
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
SchroDecoder *decoder = p_schro_params->decoder;
p_schro_params->format = schro_decoder_get_video_format (decoder);
p_schro_params->format = schro_decoder_get_video_format(decoder);
/* Tell FFmpeg about sequence details. */
if(avcodec_check_dimensions(avccontext, p_schro_params->format->width,
if (avcodec_check_dimensions(avccontext, p_schro_params->format->width,
p_schro_params->format->height) < 0) {
av_log(avccontext, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n",
p_schro_params->format->width, p_schro_params->format->height);
......@@ -180,12 +178,11 @@ 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,
if (ff_get_schro_frame_format(p_schro_params->format->chroma_format,
&p_schro_params->frame_format) == -1) {
av_log (avccontext, AV_LOG_ERROR,
av_log(avccontext, AV_LOG_ERROR,
"This codec currently only supports planar YUV 4:2:0, 4:2:2 "
"and 4:4:4 formats.\n");
return;
......@@ -221,7 +218,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
*data_size = 0;
FfmpegSchroParseContextInit (&parse_ctx, buf, buf_size);
FfmpegSchroParseContextInit(&parse_ctx, buf, buf_size);
if (!buf_size) {
if (!p_schro_params->eos_signalled) {
state = schro_decoder_push_end_of_stream(decoder);
......@@ -236,22 +233,20 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
avccontext->has_b_frames = 1;
state = schro_decoder_push (decoder, enc_buf);
state = schro_decoder_push(decoder, enc_buf);
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)
{
state = schro_decoder_wait(decoder);
switch (state) {
case SCHRO_DECODER_FIRST_ACCESS_UNIT:
libschroedinger_handle_first_access_unit (avccontext);
libschroedinger_handle_first_access_unit(avccontext);
break;
case SCHRO_DECODER_NEED_BITS:
......@@ -266,22 +261,21 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
p_schro_params->frame_format,
format->width,
format->height);
schro_decoder_add_output_picture (decoder, frame);
schro_decoder_add_output_picture(decoder, frame);
break;
case SCHRO_DECODER_OK:
/* Pull a frame out of the decoder. */
frame = schro_decoder_pull (decoder);
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:
go = 0;
p_schro_params->eos_pulled = 1;
schro_decoder_reset (decoder);
schro_decoder_reset(decoder);
outer = 0;
break;
......@@ -290,21 +284,21 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
break;
}
}
} while(outer);
} while (outer);
/* Grab next frame to be returned from the top of the queue. */
frame = ff_dirac_schro_queue_pop(&p_schro_params->dec_frame_queue);
if (frame) {
memcpy (p_schro_params->dec_pic.data[0],
memcpy(p_schro_params->dec_pic.data[0],
frame->components[0].data,
frame->components[0].length);
memcpy (p_schro_params->dec_pic.data[1],
memcpy(p_schro_params->dec_pic.data[1],
frame->components[1].data,
frame->components[1].length);
memcpy (p_schro_params->dec_pic.data[2],
memcpy(p_schro_params->dec_pic.data[2],
frame->components[2].data,
frame->components[2].length);
......@@ -316,7 +310,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
*data_size = sizeof(AVPicture);
/* Now free the frame resources. */
libschroedinger_decode_frame_free (frame);
libschroedinger_decode_frame_free(frame);
}
return buf_size;
}
......@@ -326,29 +320,29 @@ static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext)
{
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
/* Free the decoder. */
schro_decoder_free (p_schro_params->decoder);
schro_decoder_free(p_schro_params->decoder);
av_freep(&p_schro_params->format);
avpicture_free (&p_schro_params->dec_pic);
avpicture_free(&p_schro_params->dec_pic);
/* Free data in the output frame queue. */
ff_dirac_schro_queue_free (&p_schro_params->dec_frame_queue,
ff_dirac_schro_queue_free(&p_schro_params->dec_frame_queue,
libschroedinger_decode_frame_free);
return 0 ;
return 0;
}
static void libschroedinger_flush (AVCodecContext *avccontext)
static void libschroedinger_flush(AVCodecContext *avccontext)
{
/* Got a seek request. Free the decoded frames queue and then reset
* the decoder */
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
/* Free data in the output frame queue. */
ff_dirac_schro_queue_free (&p_schro_params->dec_frame_queue,
ff_dirac_schro_queue_free(&p_schro_params->dec_frame_queue,
libschroedinger_decode_frame_free);
ff_dirac_schro_queue_init (&p_schro_params->dec_frame_queue);
ff_dirac_schro_queue_init(&p_schro_params->dec_frame_queue);
schro_decoder_reset(p_schro_params->decoder);
p_schro_params->eos_pulled = 0;
p_schro_params->eos_signalled = 0;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment