diff options
Diffstat (limited to 'src/combined/ffmpeg/ffmpeg_encoder.c')
-rw-r--r-- | src/combined/ffmpeg/ffmpeg_encoder.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/combined/ffmpeg/ffmpeg_encoder.c b/src/combined/ffmpeg/ffmpeg_encoder.c index 84243a56f..d41023675 100644 --- a/src/combined/ffmpeg/ffmpeg_encoder.c +++ b/src/combined/ffmpeg/ffmpeg_encoder.c @@ -1,23 +1,23 @@ -/* +/* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a unix video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA */ - + /* mpeg encoders for the dxr3 video out plugin. */ #ifdef HAVE_CONFIG_H @@ -46,7 +46,7 @@ # include "../../libffmpeg/libavcodec/avcodec.h" #endif -/* buffer size for encoded mpeg1 stream; will hold one intra frame +/* buffer size for encoded mpeg1 stream; will hold one intra frame * at 640x480 typical sizes are <50 kB. 512 kB should be plenty */ #define DEFAULT_BUFFER_SIZE 512*1024 @@ -76,7 +76,7 @@ int dxr3_encoder_init(dxr3_driver_t *drv) lavc_data_t* this; avcodec_init(); - avcodec_register_all(); + avcodec_register_all(); lprintf("lavc init , version %x\n", avcodec_version()); this = calloc(1, sizeof(lavc_data_t)); if (!this) return 0; @@ -87,7 +87,7 @@ int dxr3_encoder_init(dxr3_driver_t *drv) this->encoder_data.on_display_frame = lavc_on_display_frame; this->encoder_data.on_unneeded = lavc_on_unneeded; this->context = 0; - + drv->enc = &this->encoder_data; return 1; } @@ -100,7 +100,7 @@ static int lavc_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) lavc_data_t *this = (lavc_data_t *)drv->enc; AVCodec *codec; unsigned char use_quantizer; - + if (this->context) { avcodec_close(this->context); free(this->context); @@ -108,27 +108,27 @@ static int lavc_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) this->context = NULL; this->picture = NULL; } - + /* if YUY2 and dimensions changed, we need to re-allocate the * internal YV12 buffer */ if (frame->vo_frame.format == XINE_IMGFMT_YUY2) { int image_size = frame->vo_frame.pitches[0] * frame->oheight; - this->out[0] = xine_xmalloc_aligned(16, image_size * 3/2, + this->out[0] = xine_xmalloc_aligned(16, image_size * 3/2, (void *)&this->buf); - this->out[1] = this->out[0] + image_size; - this->out[2] = this->out[1] + image_size/4; + this->out[1] = this->out[0] + image_size; + this->out[2] = this->out[1] + image_size/4; /* fill with black (yuv 16,128,128) */ memset(this->out[0], 16, image_size); memset(this->out[1], 128, image_size/4); memset(this->out[2], 128, image_size/4); - lprintf("Using YUY2->YV12 conversion\n"); + lprintf("Using YUY2->YV12 conversion\n"); } - + /* resolution must be a multiple of two */ if ((frame->vo_frame.pitches[0] % 2 != 0) || (frame->oheight % 2 != 0)) { - xprintf(drv->class->xine, XINE_VERBOSITY_LOG, + xprintf(drv->class->xine, XINE_VERBOSITY_LOG, "dxr3_mpeg_encoder: lavc only handles video dimensions which are multiples of 2\n"); return 0; } @@ -150,7 +150,7 @@ static int lavc_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) xprintf(drv->class->xine, XINE_VERBOSITY_LOG, "dxr3_mpeg_encoder: Couldn't start the ffmpeg library\n"); return 0; - } + } this->picture = avcodec_alloc_frame(); if (!this->picture) { xprintf(drv->class->xine, XINE_VERBOSITY_LOG, @@ -160,7 +160,7 @@ static int lavc_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) /* mpeg1 encoder only support YUV420P */ this->context->pix_fmt = PIX_FMT_YUVJ420P; - + /* put sample parameters */ this->context->bit_rate = drv->class->xine->config->register_range(drv->class->xine->config, "dxr3.encoding.lavc_bitrate", 10000, 1000, 20000, @@ -169,7 +169,7 @@ static int lavc_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) "Higher values will increase quality and CPU usage.\n" "This setting is only considered, when constant quality mode is disabled."), 10, NULL, NULL); this->context->bit_rate *= 1000; /* config in kbit/s, libavcodec wants bit/s */ - + use_quantizer = drv->class->xine->config->register_bool(drv->class->xine->config, "dxr3.encoding.lavc_quantizer", 1, _("constant quality mode"), @@ -177,18 +177,18 @@ static int lavc_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) "compressing the images based on their complexity. When disabled, libavcodec " "will use constant bitrate mode."), 10, NULL, NULL); - if (use_quantizer) { + if (use_quantizer) { this->context->qmin = drv->class->xine->config->register_range(drv->class->xine->config, "dxr3.encoding.lavc_qmin", 1, 1, 10, _("minimum compression"), _("The minimum compression to apply to an image in constant quality mode."), 10, NULL, NULL); - + this->context->qmax = drv->class->xine->config->register_range(drv->class->xine->config, "dxr3.encoding.lavc_qmax", 2, 1, 20, _("maximum quantizer"), _("The maximum compression to apply to an image in constant quality mode."), - 10, NULL, NULL); + 10, NULL, NULL); } lprintf("lavc -> bitrate %d \n", this->context->bit_rate); @@ -198,7 +198,7 @@ static int lavc_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) this->context->gop_size = 0; /*intra frames only */ this->context->me_method = ME_ZERO; /*motion estimation type*/ - + this->context->time_base.den = 90000; if (frame->vo_frame.duration > 90000 / 24) this->context->time_base.num = 90000 / 24; @@ -209,14 +209,14 @@ static int lavc_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) /* ffmpeg can complain about illegal framerates, but since this seems no * problem for the DXR3, we just tell ffmpeg to be more lax with */ this->context->strict_std_compliance = -1; - + /* open avcodec */ if (avcodec_open(this->context, codec) < 0) { xprintf(drv->class->xine, XINE_VERBOSITY_LOG, "dxr3_mpeg_encoder: could not open codec\n"); return 0; } lprintf("dxr3_mpeg_encoder: lavc MPEG1 codec opened.\n"); - + if (!this->ffmpeg_buffer) this->ffmpeg_buffer = (unsigned char *)malloc(DEFAULT_BUFFER_SIZE); /* why allocate more than needed ?! */ if (!this->ffmpeg_buffer) { @@ -233,7 +233,7 @@ static int lavc_on_display_frame(dxr3_driver_t *drv, dxr3_frame_t *frame) int size; lavc_data_t* this = (lavc_data_t *)drv->enc; ssize_t written; - + if (frame->vo_frame.bad_frame) return 1; /* ignore old frames */ if ((frame->vo_frame.pitches[0] != this->context->width) || (frame->oheight != this->context->height)) { @@ -286,7 +286,7 @@ static int lavc_prepare_frame(lavc_data_t *this, dxr3_driver_t *drv, dxr3_frame_ { int i, j, w2; uint8_t *yuy2; - + if (frame->vo_frame.bad_frame) return 1; if (frame->vo_frame.format == XINE_IMGFMT_YUY2) { @@ -322,7 +322,7 @@ static int lavc_prepare_frame(lavc_data_t *this, dxr3_driver_t *drv, dxr3_frame_ this->picture->data[1] = this->out[1]; this->picture->data[2] = this->out[2]; } - else { /* YV12 **/ + else { /* YV12 **/ this->picture->data[0] = frame->real_base[0]; this->picture->data[1] = frame->real_base[1]; this->picture->data[2] = frame->real_base[2]; |