avcodec/vc1dec: Factor (re)initializing code out
This is in preparation for removing the msmpeg4 dependency from VC-1. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
		
							parent
							
								
									5a157313b3
								
							
						
					
					
						commit
						835be33ee3
					
				@ -29,7 +29,6 @@
 | 
				
			|||||||
#include "error_resilience.h"
 | 
					#include "error_resilience.h"
 | 
				
			||||||
#include "mpeg_er.h"
 | 
					#include "mpeg_er.h"
 | 
				
			||||||
#include "mpegvideodec.h"
 | 
					#include "mpegvideodec.h"
 | 
				
			||||||
#include "msmpeg4dec.h"
 | 
					 | 
				
			||||||
#include "qpeldsp.h"
 | 
					#include "qpeldsp.h"
 | 
				
			||||||
#include "vc1.h"
 | 
					#include "vc1.h"
 | 
				
			||||||
#include "wmv2data.h"
 | 
					#include "wmv2data.h"
 | 
				
			||||||
@ -852,8 +851,8 @@ static av_cold int wmv9_init(AVCodecContext *avctx)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    ff_vc1_init_transposed_scantables(v);
 | 
					    ff_vc1_init_transposed_scantables(v);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((ret = ff_msmpeg4_decode_init(avctx)) < 0 ||
 | 
					    ret = ff_vc1_decode_init(avctx);
 | 
				
			||||||
        (ret = ff_vc1_decode_init_alloc_tables(v)) < 0)
 | 
					    if (ret < 0)
 | 
				
			||||||
        return ret;
 | 
					        return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* error concealment */
 | 
					    /* error concealment */
 | 
				
			||||||
 | 
				
			|||||||
@ -413,7 +413,7 @@ int ff_vc1_parse_frame_header    (VC1Context *v, GetBitContext *gb);
 | 
				
			|||||||
int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext *gb);
 | 
					int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext *gb);
 | 
				
			||||||
void ff_vc1_init_common(VC1Context *v);
 | 
					void ff_vc1_init_common(VC1Context *v);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int  ff_vc1_decode_init_alloc_tables(VC1Context *v);
 | 
					int  ff_vc1_decode_init(AVCodecContext *avctx);
 | 
				
			||||||
void ff_vc1_init_transposed_scantables(VC1Context *v);
 | 
					void ff_vc1_init_transposed_scantables(VC1Context *v);
 | 
				
			||||||
int  ff_vc1_decode_end(AVCodecContext *avctx);
 | 
					int  ff_vc1_decode_end(AVCodecContext *avctx);
 | 
				
			||||||
void ff_vc1_decode_blocks(VC1Context *v);
 | 
					void ff_vc1_decode_blocks(VC1Context *v);
 | 
				
			||||||
 | 
				
			|||||||
@ -329,7 +329,7 @@ static void vc1_sprite_flush(AVCodecContext *avctx)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
 | 
					static av_cold int vc1_decode_init_alloc_tables(VC1Context *v)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    MpegEncContext *s = &v->s;
 | 
					    MpegEncContext *s = &v->s;
 | 
				
			||||||
    int i, ret = AVERROR(ENOMEM);
 | 
					    int i, ret = AVERROR(ENOMEM);
 | 
				
			||||||
@ -404,10 +404,24 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
 | 
				
			|||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
error:
 | 
					error:
 | 
				
			||||||
    ff_vc1_decode_end(s->avctx);
 | 
					 | 
				
			||||||
    return ret;
 | 
					    return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int ret = ff_msmpeg4_decode_init(avctx);
 | 
				
			||||||
 | 
					    VC1Context *const v = avctx->priv_data;
 | 
				
			||||||
 | 
					    if (ret < 0)
 | 
				
			||||||
 | 
					        return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ret = vc1_decode_init_alloc_tables(v);
 | 
				
			||||||
 | 
					    if (ret < 0) {
 | 
				
			||||||
 | 
					        ff_vc1_decode_end(avctx);
 | 
				
			||||||
 | 
					        return ret;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
av_cold void ff_vc1_init_transposed_scantables(VC1Context *v)
 | 
					av_cold void ff_vc1_init_transposed_scantables(VC1Context *v)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
@ -947,12 +961,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!s->context_initialized) {
 | 
					    if (!s->context_initialized) {
 | 
				
			||||||
        if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
 | 
					        ret = ff_vc1_decode_init(avctx);
 | 
				
			||||||
 | 
					        if (ret < 0)
 | 
				
			||||||
            goto err;
 | 
					            goto err;
 | 
				
			||||||
        if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0) {
 | 
					 | 
				
			||||||
            ff_mpv_common_end(s);
 | 
					 | 
				
			||||||
            goto err;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        s->low_delay = !avctx->has_b_frames || v->res_sprite;
 | 
					        s->low_delay = !avctx->has_b_frames || v->res_sprite;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user