Commit ad092de0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

avcodec: deindent, cleanup and fix comments

No functional changes.
parent 34537022
......@@ -96,7 +96,6 @@ struct decoder_sys_t
* Local prototypes
*****************************************************************************/
static void ffmpeg_InitCodec ( decoder_t * );
static void ffmpeg_CopyPicture ( decoder_t *, picture_t *, AVFrame * );
#if LIBAVCODEC_VERSION_MAJOR >= 55
static int lavc_GetFrame(struct AVCodecContext *, AVFrame *, int);
#else
......@@ -206,6 +205,60 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,
return decoder_NewPicture( p_dec );
}
/**
* Copies a picture from the libavcodec-allocate buffer to a picture_t.
* This is used when not in direct rendering mode.
*/
static void lavc_CopyPicture(decoder_t *dec, picture_t *pic, AVFrame *frame)
{
decoder_sys_t *sys = dec->p_sys;
if (sys->p_va != NULL)
{
vlc_va_Extract(sys->p_va, pic, frame->opaque, frame->data[3]);
return;
}
if (!FindVlcChroma(sys->p_context->pix_fmt))
{
const char *name = av_get_pix_fmt_name(sys->p_context->pix_fmt);
msg_Err(dec, "Unsupported decoded output format %d (%s)",
sys->p_context->pix_fmt, (name != NULL) ? name : "unknown");
dec->b_error = true;
return;
}
for (int plane = 0; plane < pic->i_planes; plane++)
{
const uint8_t *src = frame->data[plane];
uint8_t *dst = pic->p[plane].p_pixels;
size_t src_stride = frame->linesize[plane];
size_t dst_stride = pic->p[plane].i_pitch;
size_t size = __MIN(src_stride, dst_stride);
for (int line = 0; line < pic->p[plane].i_visible_lines; line++)
{
memcpy(dst, src, size);
src += src_stride;
dst += dst_stride;
}
}
if (unlikely(sys->p_context->pix_fmt == PIX_FMT_PAL8))
{
if (pic->format.p_palette == NULL)
pic->format.p_palette = calloc(1, sizeof (video_palette_t));
if (likely(pic->format.p_palette != NULL))
{
pic->format.p_palette->i_entries = AVPALETTE_COUNT;
memcpy(pic->format.p_palette->palette, frame->data[1],
AVPALETTE_SIZE);
}
}
}
static int OpenVideoCodec( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
......@@ -762,9 +815,8 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
return NULL;
}
/* Fill p_picture_t from AVVideoFrame and do chroma conversion
* if needed */
ffmpeg_CopyPicture( p_dec, p_pic, p_sys->p_ff_pic );
/* Fill picture_t from AVFrame */
lavc_CopyPicture(p_dec, p_pic, p_sys->p_ff_pic);
}
else
{
......@@ -910,64 +962,6 @@ static void ffmpeg_InitCodec( decoder_t *p_dec )
}
}
/*****************************************************************************
* ffmpeg_CopyPicture: copy a picture from ffmpeg internal buffers to a
* picture_t structure (when not in direct rendering mode).
*****************************************************************************/
static void ffmpeg_CopyPicture( decoder_t *p_dec,
picture_t *p_pic, AVFrame *p_ff_pic )
{
decoder_sys_t *p_sys = p_dec->p_sys;
if( p_sys->p_va )
{
vlc_va_Extract( p_sys->p_va, p_pic, p_ff_pic->opaque,
p_ff_pic->data[3] );
}
else if( FindVlcChroma( p_sys->p_context->pix_fmt ) )
{
int i_plane, i_size, i_line;
uint8_t *p_dst, *p_src;
int i_src_stride, i_dst_stride;
if( p_sys->p_context->pix_fmt == PIX_FMT_PAL8 )
{
if( !p_pic->format.p_palette )
p_pic->format.p_palette = calloc( 1, sizeof(video_palette_t) );
if( p_pic->format.p_palette )
{
p_pic->format.p_palette->i_entries = AVPALETTE_COUNT;
memcpy( p_pic->format.p_palette->palette, p_ff_pic->data[1], AVPALETTE_SIZE );
}
}
for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
{
p_src = p_ff_pic->data[i_plane];
p_dst = p_pic->p[i_plane].p_pixels;
i_src_stride = p_ff_pic->linesize[i_plane];
i_dst_stride = p_pic->p[i_plane].i_pitch;
i_size = __MIN( i_src_stride, i_dst_stride );
for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines;
i_line++ )
{
memcpy( p_dst, p_src, i_size );
p_src += i_src_stride;
p_dst += i_dst_stride;
}
}
}
else
{
const char *name = av_get_pix_fmt_name( p_sys->p_context->pix_fmt );
msg_Err( p_dec, "Unsupported decoded output format %d (%s)",
p_sys->p_context->pix_fmt, name ? name : "unknown" );
p_dec->b_error = 1;
}
}
#if LIBAVCODEC_VERSION_MAJOR >= 55
static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame,
int flags)
......
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