MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / decodePacket

Function decodePacket

libhb/decavcodec.c:2056–2116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2054}
2055
2056static int decodePacket( hb_work_object_t * w )
2057{
2058 hb_work_private_t * pv = w->private_data;
2059
2060 // if this is the first frame open the codec (we have to wait for the
2061 // first frame because of M$ VC1 braindamage).
2062 if ( !pv->video_codec_opened )
2063 {
2064 AVCodecContext * context = avcodec_alloc_context3(pv->codec);
2065 if (setup_extradata(pv, context))
2066 {
2067 // we didn't find the headers needed to set up extradata.
2068 // the codec will abort if we open it so just free the buf
2069 // and hope we eventually get the info we need.
2070 hb_avcodec_free_context(&context);
2071 return HB_WORK_OK;
2072 }
2073
2074 hb_avcodec_free_context(&pv->context);
2075 pv->context = context;
2076
2077 pv->context->workaround_bugs = FF_BUG_AUTODETECT;
2078 pv->context->err_recognition = AV_EF_CRCCHECK;
2079 pv->context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK;
2080
2081 if (w->hw_device_ctx)
2082 {
2083 int ret = av_buffer_replace(&pv->context->hw_device_ctx, w->hw_device_ctx);
2084 if (ret < 0)
2085 {
2086 return HB_WORK_ERROR;
2087 }
2088 }
2089
2090 AVDictionary * av_opts = NULL;
2091 if (pv->title->flags & HBTF_NO_IDR)
2092 {
2093 av_dict_set( &av_opts, "flags", "output_corrupt", 0 );
2094 }
2095
2096 // disable threaded decoding for scan, can cause crashes
2097 if ( hb_avcodec_open( pv->context, pv->codec, &av_opts, pv->threads ) )
2098 {
2099 av_dict_free( &av_opts );
2100 hb_log( "decavcodecvWork: avcodec_open failed" );
2101 // avcodec_open can fail due to incorrectly parsed extradata
2102 // so try again when this fails
2103 av_freep( &pv->context->extradata );
2104 pv->context->extradata_size = 0;
2105 return HB_WORK_OK;
2106 }
2107 pv->context->pkt_timebase.num = pv->title->video_timebase.num;
2108 pv->context->pkt_timebase.den = pv->title->video_timebase.den;
2109 av_dict_free( &av_opts );
2110 pv->video_codec_opened = 1;
2111 }
2112
2113 decodeFrame(pv, &pv->packet_info);

Callers 2

videoParserFlushFunction · 0.85
decavcodecvWorkFunction · 0.85

Calls 5

setup_extradataFunction · 0.85
hb_avcodec_free_contextFunction · 0.85
hb_avcodec_openFunction · 0.85
hb_logFunction · 0.85
decodeFrameFunction · 0.85

Tested by

no test coverage detected