xan: make decoder independent of sizeof(AVFrame)
Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
		
							parent
							
								
									45013b365e
								
							
						
					
					
						commit
						ad438f450b
					
				| @ -52,7 +52,7 @@ | |||||||
| typedef struct XanContext { | typedef struct XanContext { | ||||||
| 
 | 
 | ||||||
|     AVCodecContext *avctx; |     AVCodecContext *avctx; | ||||||
|     AVFrame last_frame; |     AVFrame *last_frame; | ||||||
| 
 | 
 | ||||||
|     const unsigned char *buf; |     const unsigned char *buf; | ||||||
|     int size; |     int size; | ||||||
| @ -71,6 +71,8 @@ typedef struct XanContext { | |||||||
| 
 | 
 | ||||||
| } XanContext; | } XanContext; | ||||||
| 
 | 
 | ||||||
|  | static av_cold int xan_decode_end(AVCodecContext *avctx); | ||||||
|  | 
 | ||||||
| static av_cold int xan_decode_init(AVCodecContext *avctx) | static av_cold int xan_decode_init(AVCodecContext *avctx) | ||||||
| { | { | ||||||
|     XanContext *s = avctx->priv_data; |     XanContext *s = avctx->priv_data; | ||||||
| @ -90,7 +92,11 @@ static av_cold int xan_decode_init(AVCodecContext *avctx) | |||||||
|         av_freep(&s->buffer1); |         av_freep(&s->buffer1); | ||||||
|         return AVERROR(ENOMEM); |         return AVERROR(ENOMEM); | ||||||
|     } |     } | ||||||
|     avcodec_get_frame_defaults(&s->last_frame); |     s->last_frame = av_frame_alloc(); | ||||||
|  |     if (!s->last_frame) { | ||||||
|  |         xan_decode_end(avctx); | ||||||
|  |         return AVERROR(ENOMEM); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| @ -234,7 +240,7 @@ static inline void xan_wc3_copy_pixel_run(XanContext *s, AVFrame *frame, | |||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|     palette_plane = frame->data[0]; |     palette_plane = frame->data[0]; | ||||||
|     prev_palette_plane = s->last_frame.data[0]; |     prev_palette_plane = s->last_frame->data[0]; | ||||||
|     if (!prev_palette_plane) |     if (!prev_palette_plane) | ||||||
|         prev_palette_plane = palette_plane; |         prev_palette_plane = palette_plane; | ||||||
|     stride = frame->linesize[0]; |     stride = frame->linesize[0]; | ||||||
| @ -602,8 +608,8 @@ static int xan_decode_frame(AVCodecContext *avctx, | |||||||
|     if (xan_wc3_decode_frame(s, frame) < 0) |     if (xan_wc3_decode_frame(s, frame) < 0) | ||||||
|         return AVERROR_INVALIDDATA; |         return AVERROR_INVALIDDATA; | ||||||
| 
 | 
 | ||||||
|     av_frame_unref(&s->last_frame); |     av_frame_unref(s->last_frame); | ||||||
|     if ((ret = av_frame_ref(&s->last_frame, frame)) < 0) |     if ((ret = av_frame_ref(s->last_frame, frame)) < 0) | ||||||
|         return ret; |         return ret; | ||||||
| 
 | 
 | ||||||
|     *got_frame = 1; |     *got_frame = 1; | ||||||
| @ -616,7 +622,7 @@ static av_cold int xan_decode_end(AVCodecContext *avctx) | |||||||
| { | { | ||||||
|     XanContext *s = avctx->priv_data; |     XanContext *s = avctx->priv_data; | ||||||
| 
 | 
 | ||||||
|     av_frame_unref(&s->last_frame); |     av_frame_free(&s->last_frame); | ||||||
| 
 | 
 | ||||||
|     av_freep(&s->buffer1); |     av_freep(&s->buffer1); | ||||||
|     av_freep(&s->buffer2); |     av_freep(&s->buffer2); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user