Commit 0ebe3b8e authored by Diego Biurrun's avatar Diego Biurrun

cosmetics: indentation, prettyprinting, K&R coding style

Originally committed as revision 19652 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent c6438000
......@@ -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 (*free_func)(void *))
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,9 +118,9 @@ 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,
"Dirac chroma format %d not supported currently\n",
src_params->chroma);
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,
SchroFrameFormat *schro_frame_fmt);
int ff_get_schro_frame_format(SchroChromaFormat schro_chroma_fmt,
SchroFrameFormat *schro_frame_fmt);
#endif /* AVCODEC_LIBSCHROEDINGER_H */
This diff is collapsed.
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