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,7 +118,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, ...@@ -121,7 +118,7 @@ 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 */
...@@ -40,8 +40,7 @@ ...@@ -40,8 +40,7 @@
#include <schroedinger/schrovideoformat.h> #include <schroedinger/schrovideoformat.h>
/** libschroedinger decoder private data */ /** libschroedinger decoder private data */
typedef struct FfmpegSchroDecoderParams typedef struct FfmpegSchroDecoderParams {
{
/** Schroedinger video format */ /** Schroedinger video format */
SchroVideoFormat *format; SchroVideoFormat *format;
...@@ -64,24 +63,23 @@ typedef struct FfmpegSchroDecoderParams ...@@ -64,24 +63,23 @@ typedef struct FfmpegSchroDecoderParams
AVPicture dec_pic; AVPicture dec_pic;
} FfmpegSchroDecoderParams; } FfmpegSchroDecoderParams;
typedef struct FfmpegSchroParseUnitContext typedef struct FfmpegSchroParseUnitContext {
{
const uint8_t *buf; const uint8_t *buf;
int buf_size; int buf_size;
} FfmpegSchroParseUnitContext; } FfmpegSchroParseUnitContext;
static void libschroedinger_decode_buffer_free (SchroBuffer *schro_buf, static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf,
void *priv); void *priv);
static void FfmpegSchroParseContextInit (FfmpegSchroParseUnitContext *parse_ctx, static void FfmpegSchroParseContextInit(FfmpegSchroParseUnitContext *parse_ctx,
const uint8_t *buf, int buf_size) const uint8_t *buf, int buf_size)
{ {
parse_ctx->buf = buf; parse_ctx->buf = buf;
parse_ctx->buf_size = buf_size; parse_ctx->buf_size = buf_size;
} }
static SchroBuffer* FfmpegFindNextSchroParseUnit (FfmpegSchroParseUnitContext *parse_ctx) static SchroBuffer* FfmpegFindNextSchroParseUnit(FfmpegSchroParseUnitContext *parse_ctx)
{ {
SchroBuffer *enc_buf = NULL; SchroBuffer *enc_buf = NULL;
int next_pu_offset = 0; int next_pu_offset = 0;
...@@ -107,8 +105,8 @@ static SchroBuffer* FfmpegFindNextSchroParseUnit (FfmpegSchroParseUnitContext *p ...@@ -107,8 +105,8 @@ static SchroBuffer* FfmpegFindNextSchroParseUnit (FfmpegSchroParseUnitContext *p
return NULL; return NULL;
in_buf = av_malloc(next_pu_offset); in_buf = av_malloc(next_pu_offset);
memcpy (in_buf, parse_ctx->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 = schro_buffer_new_with_data(in_buf, next_pu_offset);
enc_buf->free = libschroedinger_decode_buffer_free; enc_buf->free = libschroedinger_decode_buffer_free;
enc_buf->priv = in_buf; enc_buf->priv = in_buf;
...@@ -136,7 +134,7 @@ static enum PixelFormat GetFfmpegChromaFormat(SchroChromaFormat schro_pix_fmt) ...@@ -136,7 +134,7 @@ static enum PixelFormat GetFfmpegChromaFormat(SchroChromaFormat schro_pix_fmt)
static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext) 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. */ /* First of all, initialize our supporting libraries. */
schro_init(); schro_init();
...@@ -148,17 +146,17 @@ static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext) ...@@ -148,17 +146,17 @@ static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext)
return -1; return -1;
/* Initialize the decoded frame queue. */ /* Initialize the decoded frame queue. */
ff_dirac_schro_queue_init (&p_schro_params->dec_frame_queue); ff_dirac_schro_queue_init(&p_schro_params->dec_frame_queue);
return 0 ; return 0;
} }
static void libschroedinger_decode_buffer_free (SchroBuffer *schro_buf, static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf,
void *priv) void *priv)
{ {
av_freep(&priv); av_freep(&priv);
} }
static void libschroedinger_decode_frame_free (void *frame) static void libschroedinger_decode_frame_free(void *frame)
{ {
schro_frame_unref(frame); schro_frame_unref(frame);
} }
...@@ -168,10 +166,10 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext) ...@@ -168,10 +166,10 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext)
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
SchroDecoder *decoder = p_schro_params->decoder; 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. */ /* 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) { p_schro_params->format->height) < 0) {
av_log(avccontext, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n", av_log(avccontext, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n",
p_schro_params->format->width, p_schro_params->format->height); p_schro_params->format->width, p_schro_params->format->height);
...@@ -180,12 +178,11 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext) ...@@ -180,12 +178,11 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext)
} }
avccontext->height = p_schro_params->format->height; avccontext->height = p_schro_params->format->height;
avccontext->width = p_schro_params->format->width; avccontext->width = p_schro_params->format->width;
avccontext->pix_fmt = avccontext->pix_fmt = GetFfmpegChromaFormat(p_schro_params->format->chroma_format);
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) { &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 " "This codec currently only supports planar YUV 4:2:0, 4:2:2 "
"and 4:4:4 formats.\n"); "and 4:4:4 formats.\n");
return; return;
...@@ -221,7 +218,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, ...@@ -221,7 +218,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
*data_size = 0; *data_size = 0;
FfmpegSchroParseContextInit (&parse_ctx, buf, buf_size); FfmpegSchroParseContextInit(&parse_ctx, buf, buf_size);
if (!buf_size) { if (!buf_size) {
if (!p_schro_params->eos_signalled) { if (!p_schro_params->eos_signalled) {
state = schro_decoder_push_end_of_stream(decoder); state = schro_decoder_push_end_of_stream(decoder);
...@@ -236,22 +233,20 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, ...@@ -236,22 +233,20 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) && if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0) SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
avccontext->has_b_frames = 1; 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) if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
libschroedinger_handle_first_access_unit(avccontext); libschroedinger_handle_first_access_unit(avccontext);
go = 1; go = 1;
} } else
else
outer = 0; outer = 0;
format = p_schro_params->format; format = p_schro_params->format;
while (go) { while (go) {
/* Parse data and process result. */ /* Parse data and process result. */
state = schro_decoder_wait (decoder); state = schro_decoder_wait(decoder);
switch (state) switch (state) {
{
case SCHRO_DECODER_FIRST_ACCESS_UNIT: case SCHRO_DECODER_FIRST_ACCESS_UNIT:
libschroedinger_handle_first_access_unit (avccontext); libschroedinger_handle_first_access_unit(avccontext);
break; break;
case SCHRO_DECODER_NEED_BITS: case SCHRO_DECODER_NEED_BITS:
...@@ -266,22 +261,21 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, ...@@ -266,22 +261,21 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
p_schro_params->frame_format, p_schro_params->frame_format,
format->width, format->width,
format->height); format->height);
schro_decoder_add_output_picture (decoder, frame); schro_decoder_add_output_picture(decoder, frame);
break; break;
case SCHRO_DECODER_OK: case SCHRO_DECODER_OK:
/* Pull a frame out of the decoder. */ /* Pull a frame out of the decoder. */
frame = schro_decoder_pull (decoder); frame = schro_decoder_pull(decoder);
if (frame) if (frame)
ff_dirac_schro_queue_push_back( ff_dirac_schro_queue_push_back(&p_schro_params->dec_frame_queue,
&p_schro_params->dec_frame_queue,
frame); frame);
break; break;
case SCHRO_DECODER_EOS: case SCHRO_DECODER_EOS:
go = 0; go = 0;
p_schro_params->eos_pulled = 1; p_schro_params->eos_pulled = 1;
schro_decoder_reset (decoder); schro_decoder_reset(decoder);
outer = 0; outer = 0;
break; break;
...@@ -290,21 +284,21 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, ...@@ -290,21 +284,21 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
break; break;
} }
} }
} while(outer); } while (outer);
/* Grab next frame to be returned from the top of the queue. */ /* Grab next frame to be returned from the top of the queue. */
frame = ff_dirac_schro_queue_pop(&p_schro_params->dec_frame_queue); frame = ff_dirac_schro_queue_pop(&p_schro_params->dec_frame_queue);
if (frame) { 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].data,
frame->components[0].length); 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].data,
frame->components[1].length); 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].data,
frame->components[2].length); frame->components[2].length);
...@@ -316,7 +310,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, ...@@ -316,7 +310,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
*data_size = sizeof(AVPicture); *data_size = sizeof(AVPicture);
/* Now free the frame resources. */ /* Now free the frame resources. */
libschroedinger_decode_frame_free (frame); libschroedinger_decode_frame_free(frame);
} }
return buf_size; return buf_size;
} }
...@@ -326,29 +320,29 @@ static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext) ...@@ -326,29 +320,29 @@ static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext)
{ {
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
/* Free the decoder. */ /* Free the decoder. */
schro_decoder_free (p_schro_params->decoder); schro_decoder_free(p_schro_params->decoder);
av_freep(&p_schro_params->format); 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. */ /* 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); 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 /* Got a seek request. Free the decoded frames queue and then reset
* the decoder */ * the decoder */
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
/* Free data in the output frame queue. */ /* 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); 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); schro_decoder_reset(p_schro_params->decoder);
p_schro_params->eos_pulled = 0; p_schro_params->eos_pulled = 0;
p_schro_params->eos_signalled = 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