@ -49,9 +49,9 @@
# include "hwconfig.h"
# include "hwconfig.h"
# include "internal.h"
# include "internal.h"
# include "profiles.h"
# include "profiles.h"
# include "progressframe.h"
# include "refstruct.h"
# include "refstruct.h"
# include "thread.h"
# include "thread.h"
# include "threadframe.h"
static const uint8_t hevc_pel_weight [ 65 ] = { [ 2 ] = 0 , [ 4 ] = 1 , [ 6 ] = 2 , [ 8 ] = 3 , [ 12 ] = 4 , [ 16 ] = 5 , [ 24 ] = 6 , [ 32 ] = 7 , [ 48 ] = 8 , [ 64 ] = 9 } ;
static const uint8_t hevc_pel_weight [ 65 ] = { [ 2 ] = 0 , [ 4 ] = 1 , [ 6 ] = 2 , [ 8 ] = 3 , [ 12 ] = 4 , [ 16 ] = 5 , [ 24 ] = 6 , [ 32 ] = 7 , [ 48 ] = 8 , [ 64 ] = 9 } ;
@ -1867,7 +1867,7 @@ static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref,
if ( s - > threads_type = = FF_THREAD_FRAME ) {
if ( s - > threads_type = = FF_THREAD_FRAME ) {
int y = FFMAX ( 0 , ( mv - > y > > 2 ) + y0 + height + 9 ) ;
int y = FFMAX ( 0 , ( mv - > y > > 2 ) + y0 + height + 9 ) ;
ff_thread_await_progress ( & ref - > tf , y , 0 ) ;
ff_progress_frame_await ( & ref - > tf , y ) ;
}
}
}
}
@ -3239,7 +3239,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
fail :
fail :
if ( s - > ref & & s - > threads_type = = FF_THREAD_FRAME )
if ( s - > ref & & s - > threads_type = = FF_THREAD_FRAME )
ff_thread_report_progress ( & s - > ref - > tf , INT_MAX , 0 ) ;
ff_progress_frame_report ( & s - > ref - > tf , INT_MAX ) ;
return ret ;
return ret ;
}
}
@ -3417,14 +3417,15 @@ static int hevc_ref_frame(HEVCFrame *dst, HEVCFrame *src)
{
{
int ret ;
int ret ;
ret = ff_thread_ref_frame ( & dst - > tf , & src - > tf ) ;
ff_progress_frame_ref ( & dst - > tf , & src - > tf ) ;
if ( ret < 0 )
dst - > frame = dst - > tf . f ;
return ret ;
if ( src - > needs_fg ) {
if ( src - > needs_fg ) {
ret = av_frame_ref ( dst - > frame_grain , src - > frame_grain ) ;
ret = av_frame_ref ( dst - > frame_grain , src - > frame_grain ) ;
if ( ret < 0 )
if ( ret < 0 ) {
ff_hevc_unref_frame ( dst , ~ 0 ) ;
return ret ;
return ret ;
}
dst - > needs_fg = 1 ;
dst - > needs_fg = 1 ;
}
}
@ -3464,7 +3465,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
for ( i = 0 ; i < FF_ARRAY_ELEMS ( s - > DPB ) ; i + + ) {
for ( i = 0 ; i < FF_ARRAY_ELEMS ( s - > DPB ) ; i + + ) {
ff_hevc_unref_frame ( & s - > DPB [ i ] , ~ 0 ) ;
ff_hevc_unref_frame ( & s - > DPB [ i ] , ~ 0 ) ;
av_frame_free ( & s - > DPB [ i ] . frame ) ;
av_frame_free ( & s - > DPB [ i ] . frame_grain ) ;
av_frame_free ( & s - > DPB [ i ] . frame_grain ) ;
}
}
@ -3510,11 +3510,6 @@ static av_cold int hevc_init_context(AVCodecContext *avctx)
return AVERROR ( ENOMEM ) ;
return AVERROR ( ENOMEM ) ;
for ( i = 0 ; i < FF_ARRAY_ELEMS ( s - > DPB ) ; i + + ) {
for ( i = 0 ; i < FF_ARRAY_ELEMS ( s - > DPB ) ; i + + ) {
s - > DPB [ i ] . frame = av_frame_alloc ( ) ;
if ( ! s - > DPB [ i ] . frame )
return AVERROR ( ENOMEM ) ;
s - > DPB [ i ] . tf . f = s - > DPB [ i ] . frame ;
s - > DPB [ i ] . frame_grain = av_frame_alloc ( ) ;
s - > DPB [ i ] . frame_grain = av_frame_alloc ( ) ;
if ( ! s - > DPB [ i ] . frame_grain )
if ( ! s - > DPB [ i ] . frame_grain )
return AVERROR ( ENOMEM ) ;
return AVERROR ( ENOMEM ) ;
@ -3546,7 +3541,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
for ( i = 0 ; i < FF_ARRAY_ELEMS ( s - > DPB ) ; i + + ) {
for ( i = 0 ; i < FF_ARRAY_ELEMS ( s - > DPB ) ; i + + ) {
ff_hevc_unref_frame ( & s - > DPB [ i ] , ~ 0 ) ;
ff_hevc_unref_frame ( & s - > DPB [ i ] , ~ 0 ) ;
if ( s0 - > DPB [ i ] . frame - > buf [ 0 ] ) {
if ( s0 - > DPB [ i ] . frame ) {
ret = hevc_ref_frame ( & s - > DPB [ i ] , & s0 - > DPB [ i ] ) ;
ret = hevc_ref_frame ( & s - > DPB [ i ] , & s0 - > DPB [ i ] ) ;
if ( ret < 0 )
if ( ret < 0 )
return ret ;
return ret ;
@ -3720,6 +3715,7 @@ const FFCodec ff_hevc_decoder = {
. p . capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
. p . capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS ,
AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS ,
. caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING |
. caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING |
FF_CODEC_CAP_USES_PROGRESSFRAMES |
FF_CODEC_CAP_INIT_CLEANUP ,
FF_CODEC_CAP_INIT_CLEANUP ,
. p . profiles = NULL_IF_CONFIG_SMALL ( ff_hevc_profiles ) ,
. p . profiles = NULL_IF_CONFIG_SMALL ( ff_hevc_profiles ) ,
. hw_configs = ( const AVCodecHWConfigInternal * const [ ] ) {
. hw_configs = ( const AVCodecHWConfigInternal * const [ ] ) {