@@ -187,13 +187,7 @@ public VideoDecoder(Config config, Control control = null, int uniqueId = -1, bo
187187 AVBufferRef * hwframes ;
188188 private unsafe AVPixelFormat get_format ( AVCodecContext * avctx , AVPixelFormat * pix_fmts )
189189 {
190- Log ( "get_format" ) ;
191-
192- //if (codecCtx->hw_frames_ctx == null)
193- // return AVPixelFormat.AV_PIX_FMT_NONE;
194-
195- if ( AllocateHWFrames ( ) != 0 )
196- Log ( "Hmmm..." ) ;
190+ AllocateHWFrames ( ) ;
197191
198192 return AVPixelFormat . AV_PIX_FMT_D3D11 ;
199193 }
@@ -205,10 +199,10 @@ private bool ShouldAllocateNew()
205199
206200 var t2 = ( AVHWFramesContext * ) hwframes ->data ;
207201
208- if ( codecCtx ->width != t2 ->width )
202+ if ( codecCtx ->coded_width != t2 ->width )
209203 return true ;
210204
211- if ( codecCtx ->height != t2 ->height )
205+ if ( codecCtx ->coded_height != t2 ->height )
212206 return true ;
213207
214208 var fmt = codecCtx ->sw_pix_fmt == AVPixelFormat . AV_PIX_FMT_YUV420P10LE ? AVPixelFormat . AV_PIX_FMT_P010LE : AVPixelFormat . AV_PIX_FMT_NV12 ;
@@ -222,19 +216,13 @@ private int AllocateHWFrames()
222216 if ( ! ShouldAllocateNew ( ) )
223217 {
224218 if ( hwframes != null && codecCtx ->hw_frames_ctx == null )
225- {
226219 codecCtx ->hw_frames_ctx = av_buffer_ref ( hwframes ) ;
227- Log ( "Already allocated 1" ) ;
228- }
229- else
230- Log ( "Already allocated 2" ) ;
231220
232221 textDesc . Format = textureFFmpeg . Description . Format ;
222+
233223 return 0 ;
234224 }
235225
236- Log ( "Allocating ..." ) ;
237-
238226 if ( hwframes != null )
239227 fixed( AVBufferRef * * ptr = & hwframes ) av_buffer_unref ( ptr ) ;
240228
@@ -248,8 +236,8 @@ private int AllocateHWFrames()
248236 var t2 = ( AVHWFramesContext * ) ( codecCtx ->hw_frames_ctx ->data ) ;
249237 t2 ->format = AVPixelFormat . AV_PIX_FMT_D3D11 ;
250238 t2 ->sw_format = codecCtx ->sw_pix_fmt == AVPixelFormat . AV_PIX_FMT_YUV420P10LE ? AVPixelFormat . AV_PIX_FMT_P010LE : AVPixelFormat . AV_PIX_FMT_NV12 ;
251- t2 ->width = codecCtx ->width ;
252- t2 ->height = codecCtx ->height ;
239+ t2 ->width = codecCtx ->coded_width ;
240+ t2 ->height = codecCtx ->coded_height ;
253241 t2 ->initial_pool_size = 20 ;
254242
255243 AVD3D11VAFramesContext * t3 = ( AVD3D11VAFramesContext * ) t2 ->hwctx ;
@@ -261,8 +249,8 @@ private int AllocateHWFrames()
261249 int ret = av_hwframe_ctx_init ( codecCtx ->hw_frames_ctx ) ;
262250 if ( ret == 0 )
263251 {
264- textureFFmpeg = new ID3D11Texture2D ( ( IntPtr ) t3 ->texture ) ;
265- textDesc . Format = textureFFmpeg . Description . Format ;
252+ textureFFmpeg = new ID3D11Texture2D ( ( IntPtr ) t3 ->texture ) ;
253+ textDesc . Format = textureFFmpeg . Description . Format ;
266254 }
267255
268256 return ret ;
0 commit comments