whitespace cosmetics: prettyprinting, K&R style
Originally committed as revision 20313 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
@@ -38,14 +38,16 @@
|
|||||||
/* libtheora includes */
|
/* libtheora includes */
|
||||||
#include <theora/theora.h>
|
#include <theora/theora.h>
|
||||||
|
|
||||||
typedef struct TheoraContext{
|
typedef struct TheoraContext {
|
||||||
theora_state t_state;
|
theora_state t_state;
|
||||||
} TheoraContext;
|
} TheoraContext;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Concatenates an ogg_packet into the extradata.
|
Concatenates an ogg_packet into the extradata.
|
||||||
*/
|
*/
|
||||||
static int concatenate_packet(unsigned int* offset, AVCodecContext* avc_context, const ogg_packet* packet)
|
static int concatenate_packet(unsigned int* offset,
|
||||||
|
AVCodecContext* avc_context,
|
||||||
|
const ogg_packet* packet)
|
||||||
{
|
{
|
||||||
const char* message = NULL;
|
const char* message = NULL;
|
||||||
uint8_t* newdata = NULL;
|
uint8_t* newdata = NULL;
|
||||||
@@ -71,7 +73,7 @@ static int concatenate_packet(unsigned int* offset, AVCodecContext* avc_context,
|
|||||||
avc_context->extradata_size = newsize;
|
avc_context->extradata_size = newsize;
|
||||||
AV_WB16(avc_context->extradata + (*offset), packet->bytes);
|
AV_WB16(avc_context->extradata + (*offset), packet->bytes);
|
||||||
*offset += 2;
|
*offset += 2;
|
||||||
memcpy( avc_context->extradata + (*offset), packet->packet, packet->bytes );
|
memcpy(avc_context->extradata + (*offset), packet->packet, packet->bytes);
|
||||||
(*offset) += packet->bytes;
|
(*offset) += packet->bytes;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -85,7 +87,7 @@ static av_cold int encode_init(AVCodecContext* avc_context)
|
|||||||
TheoraContext *h = avc_context->priv_data;
|
TheoraContext *h = avc_context->priv_data;
|
||||||
|
|
||||||
/* Set up the theora_info struct */
|
/* Set up the theora_info struct */
|
||||||
theora_info_init( &t_info );
|
theora_info_init(&t_info);
|
||||||
t_info.width = FFALIGN(avc_context->width, 16);
|
t_info.width = FFALIGN(avc_context->width, 16);
|
||||||
t_info.height = FFALIGN(avc_context->height, 16);
|
t_info.height = FFALIGN(avc_context->height, 16);
|
||||||
t_info.frame_width = avc_context->width;
|
t_info.frame_width = avc_context->width;
|
||||||
@@ -131,13 +133,13 @@ static av_cold int encode_init(AVCodecContext* avc_context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now initialise libtheora */
|
/* Now initialise libtheora */
|
||||||
if (theora_encode_init( &(h->t_state), &t_info ) != 0) {
|
if (theora_encode_init(&(h->t_state), &t_info) != 0) {
|
||||||
av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n");
|
av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear up theora_info struct */
|
/* Clear up theora_info struct */
|
||||||
theora_info_clear( &t_info );
|
theora_info_clear(&t_info);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Output first header packet consisting of theora
|
Output first header packet consisting of theora
|
||||||
@@ -149,24 +151,24 @@ static av_cold int encode_init(AVCodecContext* avc_context)
|
|||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
/* Header */
|
/* Header */
|
||||||
theora_encode_header( &(h->t_state), &o_packet );
|
theora_encode_header(&(h->t_state), &o_packet);
|
||||||
if (concatenate_packet( &offset, avc_context, &o_packet ) != 0)
|
if (concatenate_packet(&offset, avc_context, &o_packet) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Comment */
|
/* Comment */
|
||||||
theora_comment_init( &t_comment );
|
theora_comment_init(&t_comment);
|
||||||
theora_encode_comment( &t_comment, &o_packet );
|
theora_encode_comment(&t_comment, &o_packet);
|
||||||
if (concatenate_packet( &offset, avc_context, &o_packet ) != 0)
|
if (concatenate_packet(&offset, avc_context, &o_packet) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
/* Clear up theora_comment struct before we reset the packet */
|
/* Clear up theora_comment struct before we reset the packet */
|
||||||
theora_comment_clear( &t_comment );
|
theora_comment_clear(&t_comment);
|
||||||
/* And despite documentation to the contrary, theora_comment_clear
|
/* And despite documentation to the contrary, theora_comment_clear
|
||||||
* does not release the packet */
|
* does not release the packet */
|
||||||
ogg_packet_clear(&o_packet);
|
ogg_packet_clear(&o_packet);
|
||||||
|
|
||||||
/* Tables */
|
/* Tables */
|
||||||
theora_encode_tables( &(h->t_state), &o_packet );
|
theora_encode_tables(&(h->t_state), &o_packet);
|
||||||
if (concatenate_packet( &offset, avc_context, &o_packet ) != 0)
|
if (concatenate_packet(&offset, avc_context, &o_packet) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Set up the output AVFrame */
|
/* Set up the output AVFrame */
|
||||||
@@ -175,11 +177,8 @@ static av_cold int encode_init(AVCodecContext* avc_context)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int encode_frame(
|
static int encode_frame(AVCodecContext* avc_context, uint8_t *outbuf,
|
||||||
AVCodecContext* avc_context,
|
int buf_size, void *data)
|
||||||
uint8_t *outbuf,
|
|
||||||
int buf_size,
|
|
||||||
void *data)
|
|
||||||
{
|
{
|
||||||
yuv_buffer t_yuv_buffer;
|
yuv_buffer t_yuv_buffer;
|
||||||
TheoraContext *h = avc_context->priv_data;
|
TheoraContext *h = avc_context->priv_data;
|
||||||
@@ -207,7 +206,7 @@ static int encode_frame(
|
|||||||
t_yuv_buffer.v = frame->data[2];
|
t_yuv_buffer.v = frame->data[2];
|
||||||
|
|
||||||
/* Now call into theora_encode_YUVin */
|
/* Now call into theora_encode_YUVin */
|
||||||
result = theora_encode_YUVin( &(h->t_state), &t_yuv_buffer );
|
result = theora_encode_YUVin(&(h->t_state), &t_yuv_buffer);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
const char* message;
|
const char* message;
|
||||||
switch (result) {
|
switch (result) {
|
||||||
@@ -226,7 +225,7 @@ static int encode_frame(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Pick up returned ogg_packet */
|
/* Pick up returned ogg_packet */
|
||||||
result = theora_encode_packetout( &(h->t_state), 0, &o_packet );
|
result = theora_encode_packetout(&(h->t_state), 0, &o_packet);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case 0:
|
case 0:
|
||||||
/* No packet is ready */
|
/* No packet is ready */
|
||||||
@@ -247,7 +246,7 @@ static int encode_frame(
|
|||||||
memcpy(outbuf, o_packet.packet, o_packet.bytes);
|
memcpy(outbuf, o_packet.packet, o_packet.bytes);
|
||||||
|
|
||||||
// HACK: does not take codec delay into account (neither does the decoder though)
|
// HACK: does not take codec delay into account (neither does the decoder though)
|
||||||
avc_context->coded_frame->pts= frame->pts;
|
avc_context->coded_frame->pts = frame->pts;
|
||||||
|
|
||||||
return o_packet.bytes;
|
return o_packet.bytes;
|
||||||
}
|
}
|
||||||
@@ -259,15 +258,15 @@ static av_cold int encode_close(AVCodecContext* avc_context)
|
|||||||
int result;
|
int result;
|
||||||
const char* message;
|
const char* message;
|
||||||
|
|
||||||
result = theora_encode_packetout( &(h->t_state), 1, &o_packet );
|
result = theora_encode_packetout(&(h->t_state), 1, &o_packet);
|
||||||
theora_clear( &(h->t_state) );
|
theora_clear(&(h->t_state));
|
||||||
av_freep(&avc_context->coded_frame);
|
av_freep(&avc_context->coded_frame);
|
||||||
av_freep(&avc_context->extradata);
|
av_freep(&avc_context->extradata);
|
||||||
avc_context->extradata_size = 0;
|
avc_context->extradata_size = 0;
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case 0:/* No packet is ready */
|
case 0: /* No packet is ready */
|
||||||
case -1:/* Encoding finished */
|
case -1: /* Encoding finished */
|
||||||
return 0;
|
return 0;
|
||||||
case 1:
|
case 1:
|
||||||
/* We have a packet */
|
/* We have a packet */
|
||||||
@@ -284,8 +283,7 @@ static av_cold int encode_close(AVCodecContext* avc_context)
|
|||||||
static const enum PixelFormat supported_pixel_formats[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
|
static const enum PixelFormat supported_pixel_formats[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
|
||||||
|
|
||||||
/*! AVCodec struct exposed to libavcodec */
|
/*! AVCodec struct exposed to libavcodec */
|
||||||
AVCodec libtheora_encoder =
|
AVCodec libtheora_encoder = {
|
||||||
{
|
|
||||||
.name = "libtheora",
|
.name = "libtheora",
|
||||||
.type = CODEC_TYPE_VIDEO,
|
.type = CODEC_TYPE_VIDEO,
|
||||||
.id = CODEC_ID_THEORA,
|
.id = CODEC_ID_THEORA,
|
||||||
|
Reference in New Issue
Block a user