X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flibdiracdec.c;h=08fec3dfec0403449d24f1f2ad146e282cf81e0d;hb=0a6b1a9f21d5970a0439e32303535ed85f07673e;hp=d78893dbf2f1aabd401255b7491e0f00ece97122;hpb=7c809dc3e24a321ed0b1fc3a34442127b762f801;p=ffmpeg diff --git a/libavcodec/libdiracdec.c b/libavcodec/libdiracdec.c index d78893dbf2f..08fec3dfec0 100644 --- a/libavcodec/libdiracdec.c +++ b/libavcodec/libdiracdec.c @@ -3,31 +3,32 @@ * Copyright (c) 2005 BBC, Andrew Kennedy * Copyright (c) 2006-2008 BBC, Anuradha Suraparaju * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * FFmpeg is distributed in the hope that it will be useful, + * Libav 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** -* @file libavcodec/libdiracdec.c +* @file * Dirac decoder support via libdirac library; more details about the Dirac * project can be found at http://dirac.sourceforge.net/. * The libdirac_decoder library implements Dirac specification version 2.2 * (http://dirac.sourceforge.net/specification.html). */ +#include "libavutil/imgutils.h" #include "libdirac.h" #undef NDEBUG @@ -36,8 +37,7 @@ #include /** contains a single frame returned from Dirac */ -typedef struct FfmpegDiracDecoderParams -{ +typedef struct FfmpegDiracDecoderParams { /** decoder handle */ dirac_decoder_t* p_decoder; @@ -47,7 +47,7 @@ typedef struct FfmpegDiracDecoderParams /** -* returns FFmpeg chroma format +* returns Libav chroma format */ static enum PixelFormat GetFfmpegChromaFormat(dirac_chroma_t dirac_pix_fmt) { @@ -55,24 +55,22 @@ static enum PixelFormat GetFfmpegChromaFormat(dirac_chroma_t dirac_pix_fmt) sizeof(ffmpeg_dirac_pixel_format_map[0]); int idx; - for (idx = 0; idx < num_formats; ++idx) { - if (ffmpeg_dirac_pixel_format_map[idx].dirac_pix_fmt == dirac_pix_fmt) { + for (idx = 0; idx < num_formats; ++idx) + if (ffmpeg_dirac_pixel_format_map[idx].dirac_pix_fmt == dirac_pix_fmt) return ffmpeg_dirac_pixel_format_map[idx].ff_pix_fmt; - } - } return PIX_FMT_NONE; } 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, @@ -90,28 +88,26 @@ 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; + /* tell Libav about sequence details */ + dirac_sourceparams_t *src_params = &p_dirac_params->p_decoder->src_params; - if (avcodec_check_dimensions(avccontext, src_params->width, - src_params->height) < 0) { + if (av_image_check_size(src_params->width, src_params->height, + 0, avccontext) < 0) { av_log(avccontext, AV_LOG_ERROR, "Invalid dimensions (%dx%d)\n", src_params->width, src_params->height); avccontext->height = avccontext->width = 0; @@ -123,9 +119,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; } @@ -142,7 +138,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; @@ -179,28 +175,28 @@ 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; } -AVCodec libdirac_decoder = { +AVCodec ff_libdirac_decoder = { "libdirac", - CODEC_TYPE_VIDEO, + AVMEDIA_TYPE_VIDEO, CODEC_ID_DIRAC, sizeof(FfmpegDiracDecoderParams), libdirac_decode_init, @@ -210,4 +206,4 @@ AVCodec libdirac_decoder = { CODEC_CAP_DELAY, .flush = libdirac_flush, .long_name = NULL_IF_CONFIG_SMALL("libdirac Dirac 2.2"), -} ; +};