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[] ...@@ -45,18 +45,17 @@ static const FfmpegDiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[]
{ 4096, 2160, 24, 1 }, { 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 ret_idx = 0;
unsigned int idx; unsigned int idx;
unsigned int num_formats = sizeof(ff_dirac_schro_video_format_info) / unsigned int num_formats = sizeof(ff_dirac_schro_video_format_info) /
sizeof(ff_dirac_schro_video_format_info[0]); sizeof(ff_dirac_schro_video_format_info[0]);
for (idx = 1 ; idx < num_formats; ++idx ) { for (idx = 1; idx < num_formats; ++idx) {
const FfmpegDiracSchroVideoFormatInfo *vf = const FfmpegDiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx];
&ff_dirac_schro_video_format_info[idx];
if (avccontext->width == vf->width && if (avccontext->width == vf->width &&
avccontext->height == vf->height){ avccontext->height == vf->height) {
ret_idx = idx; ret_idx = idx;
if (avccontext->time_base.den == vf->frame_rate_num && if (avccontext->time_base.den == vf->frame_rate_num &&
avccontext->time_base.num == vf->frame_rate_denom) avccontext->time_base.num == vf->frame_rate_denom)
...@@ -66,23 +65,22 @@ unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext) ...@@ -66,23 +65,22 @@ unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext)
return ret_idx; 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->p_head = queue->p_tail = NULL;
queue->size = 0; queue->size = 0;
} }
void ff_dirac_schro_queue_free (FfmpegDiracSchroQueue *queue, void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue,
void (*free_func)(void *)) void (*free_func)(void *))
{ {
while (queue->p_head) 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 = FfmpegDiracSchroQueueElement *p_new = av_mallocz(sizeof(FfmpegDiracSchroQueueElement));
av_mallocz(sizeof(FfmpegDiracSchroQueueElement));
if (!p_new) if (!p_new)
return -1; return -1;
...@@ -99,7 +97,7 @@ int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data) ...@@ -99,7 +97,7 @@ int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data)
return 0; return 0;
} }
void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue) void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue)
{ {
FfmpegDiracSchroQueueElement *top = queue->p_head; FfmpegDiracSchroQueueElement *top = queue->p_head;
...@@ -107,7 +105,7 @@ void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue) ...@@ -107,7 +105,7 @@ void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue)
void *data = top->data; void *data = top->data;
queue->p_head = queue->p_head->next; queue->p_head = queue->p_head->next;
--queue->size; --queue->size;
av_freep (&top); av_freep(&top);
return data; return data;
} }
......
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
#include "avcodec.h" #include "avcodec.h"
typedef struct typedef struct {
{
uint16_t width; uint16_t width;
uint16_t height; uint16_t height;
uint16_t frame_rate_num; uint16_t frame_rate_num;
...@@ -39,13 +38,12 @@ typedef struct ...@@ -39,13 +38,12 @@ typedef struct
/** /**
* Returns the index into the Dirac Schro common video format info table * 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 * contains a single encoded frame returned from Dirac or Schroedinger
*/ */
typedef struct FfmpegDiracSchroEncodedFrame typedef struct FfmpegDiracSchroEncodedFrame {
{
/** encoded frame data */ /** encoded frame data */
uint8_t *p_encbuf; uint8_t *p_encbuf;
...@@ -62,8 +60,7 @@ typedef struct FfmpegDiracSchroEncodedFrame ...@@ -62,8 +60,7 @@ typedef struct FfmpegDiracSchroEncodedFrame
/** /**
* queue element * queue element
*/ */
typedef struct FfmpegDiracSchroQueueElement typedef struct FfmpegDiracSchroQueueElement {
{
/** Data to be stored in queue*/ /** Data to be stored in queue*/
void *data; void *data;
/** Pointer to next element queue */ /** Pointer to next element queue */
...@@ -74,8 +71,7 @@ typedef struct FfmpegDiracSchroQueueElement ...@@ -74,8 +71,7 @@ typedef struct FfmpegDiracSchroQueueElement
/** /**
* A simple queue implementation used in libdirac and libschroedinger * A simple queue implementation used in libdirac and libschroedinger
*/ */
typedef struct FfmpegDiracSchroQueue typedef struct FfmpegDiracSchroQueue {
{
/** Pointer to head of queue */ /** Pointer to head of queue */
FfmpegDiracSchroQueueElement *p_head; FfmpegDiracSchroQueueElement *p_head;
/** Pointer to tail of queue */ /** Pointer to tail of queue */
...@@ -92,12 +88,12 @@ void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue); ...@@ -92,12 +88,12 @@ void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue);
/** /**
* Add an element to the end of the 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 * 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 * Free the queue resources. free_func is a function supplied by the caller to
......
...@@ -36,8 +36,7 @@ ...@@ -36,8 +36,7 @@
#include <libdirac_decoder/dirac_parser.h> #include <libdirac_decoder/dirac_parser.h>
/** contains a single frame returned from Dirac */ /** contains a single frame returned from Dirac */
typedef struct FfmpegDiracDecoderParams typedef struct FfmpegDiracDecoderParams {
{
/** decoder handle */ /** decoder handle */
dirac_decoder_t* p_decoder; dirac_decoder_t* p_decoder;
...@@ -64,13 +63,13 @@ static enum PixelFormat GetFfmpegChromaFormat(dirac_chroma_t dirac_pix_fmt) ...@@ -64,13 +63,13 @@ static enum PixelFormat GetFfmpegChromaFormat(dirac_chroma_t dirac_pix_fmt)
static av_cold int libdirac_decode_init(AVCodecContext *avccontext) 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); p_dirac_params->p_decoder = dirac_decoder_init(avccontext->debug);
if (!p_dirac_params->p_decoder) if (!p_dirac_params->p_decoder)
return -1; return -1;
return 0 ; return 0;
} }
static int libdirac_decode_frame(AVCodecContext *avccontext, static int libdirac_decode_frame(AVCodecContext *avccontext,
...@@ -88,25 +87,23 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, ...@@ -88,25 +87,23 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
*data_size = 0; *data_size = 0;
if (buf_size>0) { if (buf_size > 0) {
/* set data to decode into buffer */ /* set data to decode into buffer */
dirac_buffer (p_dirac_params->p_decoder, buf, buf+buf_size); dirac_buffer(p_dirac_params->p_decoder, buf, buf + buf_size);
if ((buf[4] &0x08) == 0x08 && (buf[4] & 0x03)) if ((buf[4] & 0x08) == 0x08 && (buf[4] & 0x03))
avccontext->has_b_frames = 1; avccontext->has_b_frames = 1;
} }
while (1) { while (1) {
/* parse data and process result */ /* parse data and process result */
DecoderState state = dirac_parse (p_dirac_params->p_decoder); DecoderState state = dirac_parse(p_dirac_params->p_decoder);
switch (state) switch (state) {
{
case STATE_BUFFER: case STATE_BUFFER:
return buf_size; return buf_size;
case STATE_SEQUENCE: case STATE_SEQUENCE:
{ {
/* tell FFmpeg about sequence details */ /* tell FFmpeg about sequence details */
dirac_sourceparams_t *src_params = dirac_sourceparams_t *src_params = &p_dirac_params->p_decoder->src_params;
&p_dirac_params->p_decoder->src_params;
if (avcodec_check_dimensions(avccontext, src_params->width, if (avcodec_check_dimensions(avccontext, src_params->width,
src_params->height) < 0) { src_params->height) < 0) {
...@@ -121,9 +118,9 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, ...@@ -121,9 +118,9 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
avccontext->pix_fmt = GetFfmpegChromaFormat(src_params->chroma); avccontext->pix_fmt = GetFfmpegChromaFormat(src_params->chroma);
if (avccontext->pix_fmt == PIX_FMT_NONE) { 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", "Dirac chroma format %d not supported currently\n",
src_params->chroma); src_params->chroma);
return -1; return -1;
} }
...@@ -140,7 +137,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, ...@@ -140,7 +137,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
/* allocate output buffer */ /* allocate output buffer */
if (!p_dirac_params->p_out_frame_buf) 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[0] = p_dirac_params->p_out_frame_buf;
buffer[1] = p_dirac_params->p_out_frame_buf + buffer[1] = p_dirac_params->p_out_frame_buf +
pic.linesize[0] * avccontext->height; pic.linesize[0] * avccontext->height;
...@@ -177,20 +174,20 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, ...@@ -177,20 +174,20 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
static av_cold int libdirac_decode_close(AVCodecContext *avccontext) static av_cold int libdirac_decode_close(AVCodecContext *avccontext)
{ {
FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data; 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); 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 /* Got a seek request. We will need free memory held in the private
* context and free the current Dirac decoder handle and then open * context and free the current Dirac decoder handle and then open
* a new decoder handle. */ * a new decoder handle. */
libdirac_decode_close (avccontext); libdirac_decode_close(avccontext);
libdirac_decode_init (avccontext); libdirac_decode_init(avccontext);
return; return;
} }
...@@ -208,4 +205,4 @@ AVCodec libdirac_decoder = { ...@@ -208,4 +205,4 @@ AVCodec libdirac_decoder = {
CODEC_CAP_DELAY, CODEC_CAP_DELAY,
.flush = libdirac_flush, .flush = libdirac_flush,
.long_name = NULL_IF_CONFIG_SMALL("libdirac Dirac 2.2"), .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 ...@@ -57,8 +57,8 @@ SchroVideoFormatEnum ff_get_schro_video_format_preset(AVCodecContext *avccontext
unsigned int idx = ff_dirac_schro_get_video_format_idx (avccontext); unsigned int idx = ff_dirac_schro_get_video_format_idx (avccontext);
return (idx < num_formats) ? return (idx < num_formats) ? ff_schro_video_formats[idx] :
ff_schro_video_formats[idx] : SCHRO_VIDEO_FORMAT_CUSTOM; SCHRO_VIDEO_FORMAT_CUSTOM;
} }
int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt, int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt,
...@@ -71,8 +71,7 @@ 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) { for (idx = 0; idx < num_formats; ++idx) {
if (ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) { if (ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) {
*schro_frame_fmt = *schro_frame_fmt = ffmpeg_schro_pixel_format_map[idx].schro_frame_fmt;
ffmpeg_schro_pixel_format_map[idx].schro_frame_fmt;
return 0; return 0;
} }
} }
......
...@@ -50,7 +50,7 @@ SchroVideoFormatEnum ff_get_schro_video_format_preset (AVCodecContext *avccontex ...@@ -50,7 +50,7 @@ SchroVideoFormatEnum ff_get_schro_video_format_preset (AVCodecContext *avccontex
* Sets the Schroedinger frame format corresponding to the Schro chroma format * Sets the Schroedinger frame format corresponding to the Schro chroma format
* passed. Returns 0 on success, -1 on failure. * 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); SchroFrameFormat *schro_frame_fmt);
#endif /* AVCODEC_LIBSCHROEDINGER_H */ #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