Commit 8d935b14 authored by Steve Lhomme's avatar Steve Lhomme

transcode: use a picture pool created by the encoder for the encoder output buffers

This is similar to what vout_update_format() does, except the picture pool is
created by the encoder rather than the vout.

This will allow direct transcoding via GPU buffers.
parent b0b5bd30
......@@ -30,6 +30,7 @@
#include <vlc_es.h>
#include <vlc_picture.h>
#include <vlc_subpicture.h>
#include <vlc_picture_pool.h>
/**
* \defgroup codec Codec
......@@ -225,6 +226,7 @@ struct encoder_t
block_t * ( * pf_encode_video )( encoder_t *, picture_t * );
block_t * ( * pf_encode_audio )( encoder_t *, block_t * );
block_t * ( * pf_encode_sub )( encoder_t *, subpicture_t * );
picture_pool_t * ( * pf_input_pool )( encoder_t *, unsigned );
/* Common encoder options */
int i_threads; /* Number of threads to use during encoding */
......
......@@ -1617,7 +1617,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
post_mt(p_sys);
picture_t *test_pic = decoder_NewPicture(p_dec);
assert(!test_pic || test_pic->format.i_chroma == p_dec->fmt_out.video.i_chroma);
//assert(!test_pic || test_pic->format.i_chroma == p_dec->fmt_out.video.i_chroma);
vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, hwfmt,
&p_dec->fmt_in,
test_pic ? test_pic->p_sys : NULL);
......
......@@ -109,6 +109,7 @@ struct sout_stream_id_sys_t
struct filter_pool *p_pool;
filter_chain_t *p_uf_chain; /**< User-specified video filters */
video_format_t fmt_input_video;
picture_pool_t *p_dec_pool;
};
struct
{
......
......@@ -83,6 +83,11 @@ static int video_update_format_decoder( decoder_t *p_dec )
return chain_works;
}
static picture_pool_t *default_input_pool( encoder_t *p_enc, unsigned pool_size )
{
return picture_pool_NewFromFormat( &p_enc->fmt_in.video, pool_size );
}
static picture_t *video_new_buffer_decoder( decoder_t *p_dec )
{
sout_stream_t *stream = (sout_stream_t*) p_dec->p_owner;
......@@ -91,6 +96,30 @@ static picture_t *video_new_buffer_decoder( decoder_t *p_dec )
if (unlikely(!id->p_encoder->p_module))
create_encoder(stream, id);
if (unlikely(id->p_dec_pool == NULL))
{
unsigned dpb_size;
switch( p_dec->fmt_in.i_codec )
{
case VLC_CODEC_HEVC:
case VLC_CODEC_H264:
case VLC_CODEC_DIRAC: /* FIXME valid ? */
dpb_size = 18;
break;
case VLC_CODEC_VP5:
case VLC_CODEC_VP6:
case VLC_CODEC_VP6F:
case VLC_CODEC_VP8:
dpb_size = 3;
break;
default:
dpb_size = 2;
break;
}
id->p_dec_pool = id->p_encoder->pf_input_pool( id->p_encoder, dpb_size );
}
if (likely(id->p_dec_pool))
return picture_pool_Get( id->p_dec_pool );
return picture_NewFromFormat( &p_dec->fmt_out.video );
}
......@@ -250,6 +279,7 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_sys_t *i
id->p_encoder->i_threads = p_sys->i_threads;
id->p_encoder->p_cfg = p_sys->p_video_cfg;
id->p_encoder->pf_input_pool = default_input_pool;
id->p_encoder->p_module =
module_need( id->p_encoder, "encoder", p_sys->psz_venc, true );
......
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