There are two types of MPVPictures: Three (cur_pic, last_pic, next_pic) that are directly part of MpegEncContext and an array of MPVPictures that are separately allocated and are mostly accessed via pointers (cur|last|next)_pic_ptr; they are also used to store AVFrames in the encoder (necessary due to B-frames). As the name implies, each of the former is directly associated with one of the _ptr pointers: They actually share the same underlying buffers, but the ones that are part of the context can have their data pointers offset and their linesize doubled for field pictures. Up until now, each of these had their own references; in particular, there was an underlying av_frame_ref() to sync cur_pic and cur_pic_ptr etc. This is wasteful. This commit changes this relationship: cur_pic, last_pic and next_pic now become MPVWorkPictures; this structure does not have an AVFrame at all any more, but only the cached values of data and linesize. It also contains a pointer to the corresponding MPVPicture, establishing a more natural relationsship between the two. This already means that creating the context-pictures from the pointers can no longer fail. What has not been changed is the fact that the MPVPicture* pointers are not ownership pointers and that the MPVPictures are part of an array of MPVPictures that is owned by a single AVCodecContext. Doing so will be done in a latter commit.
Unified · Split
| @@ -44,7 +44,7 @@ static int d3d12va_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint · 43 unmodified lines | |||
| 44 | { | 44 | { |
| 45 | const MpegEncContext *s = avctx->priv_data; | 45 | const MpegEncContext *s = avctx->priv_data; |
| 46 | D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); | 46 | D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); |
| 47 | D3D12DecodePictureContext *ctx_pic = s->cur_pic_ptr->hwaccel_picture_private; | 47 | D3D12DecodePictureContext *ctx_pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 48 | 48 | ||
| 49 | if (!ctx) | 49 | if (!ctx) |
| 50 | return -1; | 50 | return -1; |
| @@ -69,7 +69,7 @@ static int d3d12va_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint · 18 unmodified lines | |||
| 69 | static int d3d12va_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | 69 | static int d3d12va_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) |
| 70 | { | 70 | { |
| 71 | const MpegEncContext *s = avctx->priv_data; | 71 | const MpegEncContext *s = avctx->priv_data; |
| 72 | D3D12DecodePictureContext *ctx_pic = s->cur_pic_ptr->hwaccel_picture_private; | 72 | D3D12DecodePictureContext *ctx_pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 73 | 73 | ||
| 74 | if (ctx_pic->slice_count >= MAX_SLICES) { | 74 | if (ctx_pic->slice_count >= MAX_SLICES) { |
| 75 | return AVERROR(ERANGE); | 75 | return AVERROR(ERANGE); |
| @@ -88,7 +88,7 @@ static int d3d12va_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buff · 12 unmodified lines | |||
| 88 | static int update_input_arguments(AVCodecContext *avctx, D3D12_VIDEO_DECODE_INPUT_STREAM_ARGUMENTS *input_args, ID3D12Resource *buffer) | 88 | static int update_input_arguments(AVCodecContext *avctx, D3D12_VIDEO_DECODE_INPUT_STREAM_ARGUMENTS *input_args, ID3D12Resource *buffer) |
| 89 | { | 89 | { |
| 90 | const MpegEncContext *s = avctx->priv_data; | 90 | const MpegEncContext *s = avctx->priv_data; |
| 91 | D3D12DecodePictureContext *ctx_pic = s->cur_pic_ptr->hwaccel_picture_private; | 91 | D3D12DecodePictureContext *ctx_pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 92 | 92 | ||
| 93 | const int is_field = s->picture_structure != PICT_FRAME; | 93 | const int is_field = s->picture_structure != PICT_FRAME; |
| 94 | const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); | 94 | const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); |
| @@ -137,12 +137,12 @@ static int d3d12va_mpeg2_end_frame(AVCodecContext *avctx) · 42 unmodified lines | |||
| 137 | { | 137 | { |
| 138 | int ret; | 138 | int ret; |
| 139 | MpegEncContext *s = avctx->priv_data; | 139 | MpegEncContext *s = avctx->priv_data; |
| 140 | D3D12DecodePictureContext *ctx_pic = s->cur_pic_ptr->hwaccel_picture_private; | 140 | D3D12DecodePictureContext *ctx_pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 141 | 141 | ||
| 142 | if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) | 142 | if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) |
| 143 | return -1; | 143 | return -1; |
| 144 | 144 | ||
| 145 | ret = ff_d3d12va_common_end_frame(avctx, s->cur_pic_ptr->f, &ctx_pic->pp, sizeof(ctx_pic->pp), | 145 | ret = ff_d3d12va_common_end_frame(avctx, s->cur_pic.ptr->f, &ctx_pic->pp, sizeof(ctx_pic->pp), |
| 146 | &ctx_pic->qm, sizeof(ctx_pic->qm), update_input_arguments); | 146 | &ctx_pic->qm, sizeof(ctx_pic->qm), update_input_arguments); |
| 147 | if (!ret) | 147 | if (!ret) |
| 148 | ff_mpeg_draw_horiz_band(s, 0, avctx->height); | 148 | ff_mpeg_draw_horiz_band(s, 0, avctx->height); |
| @@ -45,7 +45,7 @@ static int d3d12va_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_ · 44 unmodified lines | |||
| 45 | { | 45 | { |
| 46 | const VC1Context *v = avctx->priv_data; | 46 | const VC1Context *v = avctx->priv_data; |
| 47 | D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); | 47 | D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); |
| 48 | D3D12DecodePictureContext *ctx_pic = v->s.cur_pic_ptr->hwaccel_picture_private; | 48 | D3D12DecodePictureContext *ctx_pic = v->s.cur_pic.ptr->hwaccel_picture_private; |
| 49 | 49 | ||
| 50 | if (!ctx) | 50 | if (!ctx) |
| 51 | return -1; | 51 | return -1; |
| @@ -67,7 +67,7 @@ static int d3d12va_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_ · 15 unmodified lines | |||
| 67 | static int d3d12va_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | 67 | static int d3d12va_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) |
| 68 | { | 68 | { |
| 69 | const VC1Context *v = avctx->priv_data; | 69 | const VC1Context *v = avctx->priv_data; |
| 70 | D3D12DecodePictureContext *ctx_pic = v->s.cur_pic_ptr->hwaccel_picture_private; | 70 | D3D12DecodePictureContext *ctx_pic = v->s.cur_pic.ptr->hwaccel_picture_private; |
| 71 | 71 | ||
| 72 | if (ctx_pic->slice_count >= MAX_SLICES) { | 72 | if (ctx_pic->slice_count >= MAX_SLICES) { |
| 73 | return AVERROR(ERANGE); | 73 | return AVERROR(ERANGE); |
| @@ -93,7 +93,7 @@ static int update_input_arguments(AVCodecContext *avctx, D3D12_VIDEO_DECODE_INPU · 19 unmodified lines | |||
| 93 | { | 93 | { |
| 94 | const VC1Context *v = avctx->priv_data; | 94 | const VC1Context *v = avctx->priv_data; |
| 95 | const MpegEncContext *s = &v->s; | 95 | const MpegEncContext *s = &v->s; |
| 96 | D3D12DecodePictureContext *ctx_pic = s->cur_pic_ptr->hwaccel_picture_private; | 96 | D3D12DecodePictureContext *ctx_pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 97 | D3D12_VIDEO_DECODE_FRAME_ARGUMENT *args = &input_args->FrameArguments[input_args->NumFrameArguments++]; | 97 | D3D12_VIDEO_DECODE_FRAME_ARGUMENT *args = &input_args->FrameArguments[input_args->NumFrameArguments++]; |
| 98 | 98 | ||
| 99 | const unsigned mb_count = s->mb_width * (s->mb_height >> v->field_mode); | 99 | const unsigned mb_count = s->mb_width * (s->mb_height >> v->field_mode); |
| @@ -151,12 +151,12 @@ static int update_input_arguments(AVCodecContext *avctx, D3D12_VIDEO_DECODE_INPU · 51 unmodified lines | |||
| 151 | static int d3d12va_vc1_end_frame(AVCodecContext *avctx) | 151 | static int d3d12va_vc1_end_frame(AVCodecContext *avctx) |
| 152 | { | 152 | { |
| 153 | const VC1Context *v = avctx->priv_data; | 153 | const VC1Context *v = avctx->priv_data; |
| 154 | D3D12DecodePictureContext *ctx_pic = v->s.cur_pic_ptr->hwaccel_picture_private; | 154 | D3D12DecodePictureContext *ctx_pic = v->s.cur_pic.ptr->hwaccel_picture_private; |
| 155 | 155 | ||
| 156 | if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) | 156 | if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) |
| 157 | return -1; | 157 | return -1; |
| 158 | 158 | ||
| 159 | return ff_d3d12va_common_end_frame(avctx, v->s.cur_pic_ptr->f, | 159 | return ff_d3d12va_common_end_frame(avctx, v->s.cur_pic.ptr->f, |
| 160 | &ctx_pic->pp, sizeof(ctx_pic->pp), | 160 | &ctx_pic->pp, sizeof(ctx_pic->pp), |
| 161 | NULL, 0, | 161 | NULL, 0, |
| 162 | update_input_arguments); | 162 | update_input_arguments); |
| @@ -45,17 +45,17 @@ void ff_dxva2_mpeg2_fill_picture_parameters(AVCodecContext *avctx, · 44 unmodified lines | |||
| 45 | DXVA_PictureParameters *pp) | 45 | DXVA_PictureParameters *pp) |
| 46 | { | 46 | { |
| 47 | const struct MpegEncContext *s = avctx->priv_data; | 47 | const struct MpegEncContext *s = avctx->priv_data; |
| 48 | const MPVPicture *current_picture = s->cur_pic_ptr; | 48 | const MPVPicture *current_picture = s->cur_pic.ptr; |
| 49 | int is_field = s->picture_structure != PICT_FRAME; | 49 | int is_field = s->picture_structure != PICT_FRAME; |
| 50 | 50 | ||
| 51 | memset(pp, 0, sizeof(*pp)); | 51 | memset(pp, 0, sizeof(*pp)); |
| 52 | pp->wDeblockedPictureIndex = 0; | 52 | pp->wDeblockedPictureIndex = 0; |
| 53 | if (s->pict_type != AV_PICTURE_TYPE_I) | 53 | if (s->pict_type != AV_PICTURE_TYPE_I) |
| 54 | pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, s->last_pic.f, 0); | 54 | pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, s->last_pic.ptr->f, 0); |
| 55 | else | 55 | else |
| 56 | pp->wForwardRefPictureIndex = 0xffff; | 56 | pp->wForwardRefPictureIndex = 0xffff; |
| 57 | if (s->pict_type == AV_PICTURE_TYPE_B) | 57 | if (s->pict_type == AV_PICTURE_TYPE_B) |
| 58 | pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, s->next_pic.f, 0); | 58 | pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, s->next_pic.ptr->f, 0); |
| 59 | else | 59 | else |
| 60 | pp->wBackwardRefPictureIndex = 0xffff; | 60 | pp->wBackwardRefPictureIndex = 0xffff; |
| 61 | pp->wDecodedPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, current_picture->f, 1); | 61 | pp->wDecodedPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, current_picture->f, 1); |
| @@ -157,7 +157,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 95 unmodified lines | |||
| 157 | const struct MpegEncContext *s = avctx->priv_data; | 157 | const struct MpegEncContext *s = avctx->priv_data; |
| 158 | AVDXVAContext *ctx = DXVA_CONTEXT(avctx); | 158 | AVDXVAContext *ctx = DXVA_CONTEXT(avctx); |
| 159 | struct dxva2_picture_context *ctx_pic = | 159 | struct dxva2_picture_context *ctx_pic = |
| 160 | s->cur_pic_ptr->hwaccel_picture_private; | 160 | s->cur_pic.ptr->hwaccel_picture_private; |
| 161 | const int is_field = s->picture_structure != PICT_FRAME; | 161 | const int is_field = s->picture_structure != PICT_FRAME; |
| 162 | const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); | 162 | const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); |
| 163 | void *dxva_data_ptr; | 163 | void *dxva_data_ptr; |
| @@ -260,7 +260,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, · 96 unmodified lines | |||
| 260 | const struct MpegEncContext *s = avctx->priv_data; | 260 | const struct MpegEncContext *s = avctx->priv_data; |
| 261 | AVDXVAContext *ctx = DXVA_CONTEXT(avctx); | 261 | AVDXVAContext *ctx = DXVA_CONTEXT(avctx); |
| 262 | struct dxva2_picture_context *ctx_pic = | 262 | struct dxva2_picture_context *ctx_pic = |
| 263 | s->cur_pic_ptr->hwaccel_picture_private; | 263 | s->cur_pic.ptr->hwaccel_picture_private; |
| 264 | 264 | ||
| 265 | if (!DXVA_CONTEXT_VALID(avctx, ctx)) | 265 | if (!DXVA_CONTEXT_VALID(avctx, ctx)) |
| 266 | return -1; | 266 | return -1; |
| @@ -280,7 +280,7 @@ static int dxva2_mpeg2_decode_slice(AVCodecContext *avctx, · 13 unmodified lines | |||
| 280 | { | 280 | { |
| 281 | const struct MpegEncContext *s = avctx->priv_data; | 281 | const struct MpegEncContext *s = avctx->priv_data; |
| 282 | struct dxva2_picture_context *ctx_pic = | 282 | struct dxva2_picture_context *ctx_pic = |
| 283 | s->cur_pic_ptr->hwaccel_picture_private; | 283 | s->cur_pic.ptr->hwaccel_picture_private; |
| 284 | unsigned position; | 284 | unsigned position; |
| 285 | 285 | ||
| 286 | if (ctx_pic->slice_count >= MAX_SLICES) { | 286 | if (ctx_pic->slice_count >= MAX_SLICES) { |
| @@ -302,12 +302,12 @@ static int dxva2_mpeg2_end_frame(AVCodecContext *avctx) · 15 unmodified lines | |||
| 302 | { | 302 | { |
| 303 | struct MpegEncContext *s = avctx->priv_data; | 303 | struct MpegEncContext *s = avctx->priv_data; |
| 304 | struct dxva2_picture_context *ctx_pic = | 304 | struct dxva2_picture_context *ctx_pic = |
| 305 | s->cur_pic_ptr->hwaccel_picture_private; | 305 | s->cur_pic.ptr->hwaccel_picture_private; |
| 306 | int ret; | 306 | int ret; |
| 307 | 307 | ||
| 308 | if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) | 308 | if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) |
| 309 | return -1; | 309 | return -1; |
| 310 | ret = ff_dxva2_common_end_frame(avctx, s->cur_pic_ptr->f, | 310 | ret = ff_dxva2_common_end_frame(avctx, s->cur_pic.ptr->f, |
| 311 | &ctx_pic->pp, sizeof(ctx_pic->pp), | 311 | &ctx_pic->pp, sizeof(ctx_pic->pp), |
| 312 | &ctx_pic->qm, sizeof(ctx_pic->qm), | 312 | &ctx_pic->qm, sizeof(ctx_pic->qm), |
| 313 | commit_bitstream_and_slice_buffer); | 313 | commit_bitstream_and_slice_buffer); |
| @@ -46,7 +46,7 @@ void ff_dxva2_vc1_fill_picture_parameters(AVCodecContext *avctx, · 45 unmodified lines | |||
| 46 | { | 46 | { |
| 47 | const VC1Context *v = avctx->priv_data; | 47 | const VC1Context *v = avctx->priv_data; |
| 48 | const MpegEncContext *s = &v->s; | 48 | const MpegEncContext *s = &v->s; |
| 49 | const MPVPicture *current_picture = s->cur_pic_ptr; | 49 | const MPVPicture *current_picture = s->cur_pic.ptr; |
| 50 | int intcomp = 0; | 50 | int intcomp = 0; |
| 51 | 51 | ||
| 52 | // determine if intensity compensation is needed | 52 | // determine if intensity compensation is needed |
| @@ -58,12 +58,12 @@ void ff_dxva2_vc1_fill_picture_parameters(AVCodecContext *avctx, · 5 unmodified lines | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | memset(pp, 0, sizeof(*pp)); | 60 | memset(pp, 0, sizeof(*pp)); |
| 61 | if (s->pict_type != AV_PICTURE_TYPE_I && !v->bi_type) | 61 | if (s->pict_type != AV_PICTURE_TYPE_I && !v->bi_type && s->last_pic.ptr) |
| 62 | pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, s->last_pic.f, 0); | 62 | pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, s->last_pic.ptr->f, 0); |
| 63 | else | 63 | else |
| 64 | pp->wForwardRefPictureIndex = 0xffff; | 64 | pp->wForwardRefPictureIndex = 0xffff; |
| 65 | if (s->pict_type == AV_PICTURE_TYPE_B && !v->bi_type) | 65 | if (s->pict_type == AV_PICTURE_TYPE_B && !v->bi_type && s->next_pic.ptr) |
| 66 | pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, s->next_pic.f, 0); | 66 | pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, s->next_pic.ptr->f, 0); |
| 67 | else | 67 | else |
| 68 | pp->wBackwardRefPictureIndex = 0xffff; | 68 | pp->wBackwardRefPictureIndex = 0xffff; |
| 69 | pp->wDecodedPictureIndex = | 69 | pp->wDecodedPictureIndex = |
| @@ -191,7 +191,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 121 unmodified lines | |||
| 191 | const VC1Context *v = avctx->priv_data; | 191 | const VC1Context *v = avctx->priv_data; |
| 192 | AVDXVAContext *ctx = DXVA_CONTEXT(avctx); | 192 | AVDXVAContext *ctx = DXVA_CONTEXT(avctx); |
| 193 | const MpegEncContext *s = &v->s; | 193 | const MpegEncContext *s = &v->s; |
| 194 | struct dxva2_picture_context *ctx_pic = s->cur_pic_ptr->hwaccel_picture_private; | 194 | struct dxva2_picture_context *ctx_pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 195 | 195 | ||
| 196 | static const uint8_t start_code[] = { 0, 0, 1, 0x0d }; | 196 | static const uint8_t start_code[] = { 0, 0, 1, 0x0d }; |
| 197 | const unsigned start_code_size = avctx->codec_id == AV_CODEC_ID_VC1 ? sizeof(start_code) : 0; | 197 | const unsigned start_code_size = avctx->codec_id == AV_CODEC_ID_VC1 ? sizeof(start_code) : 0; |
| @@ -317,7 +317,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx, · 119 unmodified lines | |||
| 317 | { | 317 | { |
| 318 | const VC1Context *v = avctx->priv_data; | 318 | const VC1Context *v = avctx->priv_data; |
| 319 | AVDXVAContext *ctx = DXVA_CONTEXT(avctx); | 319 | AVDXVAContext *ctx = DXVA_CONTEXT(avctx); |
| 320 | struct dxva2_picture_context *ctx_pic = v->s.cur_pic_ptr->hwaccel_picture_private; | 320 | struct dxva2_picture_context *ctx_pic = v->s.cur_pic.ptr->hwaccel_picture_private; |
| 321 | 321 | ||
| 322 | if (!DXVA_CONTEXT_VALID(avctx, ctx)) | 322 | if (!DXVA_CONTEXT_VALID(avctx, ctx)) |
| 323 | return -1; | 323 | return -1; |
| @@ -336,7 +336,7 @@ static int dxva2_vc1_decode_slice(AVCodecContext *avctx, · 12 unmodified lines | |||
| 336 | uint32_t size) | 336 | uint32_t size) |
| 337 | { | 337 | { |
| 338 | const VC1Context *v = avctx->priv_data; | 338 | const VC1Context *v = avctx->priv_data; |
| 339 | const MPVPicture *current_picture = v->s.cur_pic_ptr; | 339 | const MPVPicture *current_picture = v->s.cur_pic.ptr; |
| 340 | struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; | 340 | struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; |
| 341 | unsigned position; | 341 | unsigned position; |
| 342 | 342 | ||
| @@ -364,13 +364,13 @@ static int dxva2_vc1_decode_slice(AVCodecContext *avctx, · 21 unmodified lines | |||
| 364 | static int dxva2_vc1_end_frame(AVCodecContext *avctx) | 364 | static int dxva2_vc1_end_frame(AVCodecContext *avctx) |
| 365 | { | 365 | { |
| 366 | VC1Context *v = avctx->priv_data; | 366 | VC1Context *v = avctx->priv_data; |
| 367 | struct dxva2_picture_context *ctx_pic = v->s.cur_pic_ptr->hwaccel_picture_private; | 367 | struct dxva2_picture_context *ctx_pic = v->s.cur_pic.ptr->hwaccel_picture_private; |
| 368 | int ret; | 368 | int ret; |
| 369 | 369 | ||
| 370 | if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) | 370 | if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) |
| 371 | return -1; | 371 | return -1; |
| 372 | 372 | ||
| 373 | ret = ff_dxva2_common_end_frame(avctx, v->s.cur_pic_ptr->f, | 373 | ret = ff_dxva2_common_end_frame(avctx, v->s.cur_pic.ptr->f, |
| 374 | &ctx_pic->pp, sizeof(ctx_pic->pp), | 374 | &ctx_pic->pp, sizeof(ctx_pic->pp), |
| 375 | NULL, 0, | 375 | NULL, 0, |
| 376 | commit_bitstream_and_slice_buffer); | 376 | commit_bitstream_and_slice_buffer); |
| @@ -649,12 +649,11 @@ static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 648 unmodified lines | |||
| 649 | } | 649 | } |
| 650 | ff_mpv_frame_end(s); | 650 | ff_mpv_frame_end(s); |
| 651 | 651 | ||
| 652 | av_assert0(s->cur_pic.f->pict_type == s->cur_pic_ptr->f->pict_type); | 652 | av_assert0(s->pict_type == s->cur_pic.ptr->f->pict_type); |
| 653 | av_assert0(s->cur_pic.f->pict_type == s->pict_type); | ||
| 654 | 653 | ||
| 655 | if ((ret = av_frame_ref(pict, s->cur_pic_ptr->f)) < 0) | 654 | if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0) |
| 656 | return ret; | 655 | return ret; |
| 657 | ff_print_debug_info(s, s->cur_pic_ptr, pict); | 656 | ff_print_debug_info(s, s->cur_pic.ptr, pict); |
| 658 | 657 | ||
| 659 | *got_frame = 1; | 658 | *got_frame = 1; |
| 660 | 659 | ||
| @@ -432,22 +432,22 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 431 unmodified lines | |||
| 432 | /* no supplementary picture */ | 432 | /* no supplementary picture */ |
| 433 | if (buf_size == 0) { | 433 | if (buf_size == 0) { |
| 434 | /* special case for last picture */ | 434 | /* special case for last picture */ |
| 435 | if (s->low_delay == 0 && s->next_pic_ptr) { | 435 | if (s->low_delay == 0 && s->next_pic.ptr) { |
| 436 | if ((ret = av_frame_ref(pict, s->next_pic_ptr->f)) < 0) | 436 | if ((ret = av_frame_ref(pict, s->next_pic.ptr->f)) < 0) |
| 437 | return ret; | 437 | return ret; |
| 438 | s->next_pic_ptr = NULL; | 438 | s->next_pic.ptr = NULL; |
| 439 | 439 | ||
| 440 | *got_frame = 1; | 440 | *got_frame = 1; |
| 441 | } else if (s->skipped_last_frame && s->cur_pic_ptr) { | 441 | } else if (s->skipped_last_frame && s->cur_pic.ptr) { |
| 442 | /* Output the last picture we decoded again if the stream ended with | 442 | /* Output the last picture we decoded again if the stream ended with |
| 443 | * an NVOP */ | 443 | * an NVOP */ |
| 444 | if ((ret = av_frame_ref(pict, s->cur_pic_ptr->f)) < 0) | 444 | if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0) |
| 445 | return ret; | 445 | return ret; |
| 446 | /* Copy props from the last input packet. Otherwise, props from the last | 446 | /* Copy props from the last input packet. Otherwise, props from the last |
| 447 | * returned picture would be reused */ | 447 | * returned picture would be reused */ |
| 448 | if ((ret = ff_decode_frame_props(avctx, pict)) < 0) | 448 | if ((ret = ff_decode_frame_props(avctx, pict)) < 0) |
| 449 | return ret; | 449 | return ret; |
| 450 | s->cur_pic_ptr = NULL; | 450 | s->cur_pic.ptr = NULL; |
| 451 | 451 | ||
| 452 | *got_frame = 1; | 452 | *got_frame = 1; |
| 453 | } | 453 | } |
| @@ -561,7 +561,7 @@ retry: · 107 unmodified lines | |||
| 561 | s->gob_index = H263_GOB_HEIGHT(s->height); | 561 | s->gob_index = H263_GOB_HEIGHT(s->height); |
| 562 | 562 | ||
| 563 | /* skip B-frames if we don't have reference frames */ | 563 | /* skip B-frames if we don't have reference frames */ |
| 564 | if (!s->last_pic_ptr && | 564 | if (!s->last_pic.ptr && |
| 565 | (s->pict_type == AV_PICTURE_TYPE_B || s->droppable)) | 565 | (s->pict_type == AV_PICTURE_TYPE_B || s->droppable)) |
| 566 | return get_consumed_bytes(s, buf_size); | 566 | return get_consumed_bytes(s, buf_size); |
| 567 | if ((avctx->skip_frame >= AVDISCARD_NONREF && | 567 | if ((avctx->skip_frame >= AVDISCARD_NONREF && |
| @@ -647,21 +647,20 @@ frame_end: · 79 unmodified lines | |||
| 647 | if (!s->divx_packed && avctx->hwaccel) | 647 | if (!s->divx_packed && avctx->hwaccel) |
| 648 | ff_thread_finish_setup(avctx); | 648 | ff_thread_finish_setup(avctx); |
| 649 | 649 | ||
| 650 | av_assert1(s->cur_pic.f->pict_type == s->cur_pic_ptr->f->pict_type); | 650 | av_assert1(s->pict_type == s->cur_pic.ptr->f->pict_type); |
| 651 | av_assert1(s->cur_pic.f->pict_type == s->pict_type); | ||
| 652 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { | 651 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { |
| 653 | if ((ret = av_frame_ref(pict, s->cur_pic_ptr->f)) < 0) | 652 | if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0) |
| 654 | return ret; | 653 | return ret; |
| 655 | ff_print_debug_info(s, s->cur_pic_ptr, pict); | 654 | ff_print_debug_info(s, s->cur_pic.ptr, pict); |
| 656 | ff_mpv_export_qp_table(s, pict, s->cur_pic_ptr, FF_MPV_QSCALE_TYPE_MPEG1); | 655 | ff_mpv_export_qp_table(s, pict, s->cur_pic.ptr, FF_MPV_QSCALE_TYPE_MPEG1); |
| 657 | } else if (s->last_pic_ptr) { | 656 | } else if (s->last_pic.ptr) { |
| 658 | if ((ret = av_frame_ref(pict, s->last_pic_ptr->f)) < 0) | 657 | if ((ret = av_frame_ref(pict, s->last_pic.ptr->f)) < 0) |
| 659 | return ret; | 658 | return ret; |
| 660 | ff_print_debug_info(s, s->last_pic_ptr, pict); | 659 | ff_print_debug_info(s, s->last_pic.ptr, pict); |
| 661 | ff_mpv_export_qp_table(s, pict, s->last_pic_ptr, FF_MPV_QSCALE_TYPE_MPEG1); | 660 | ff_mpv_export_qp_table(s, pict, s->last_pic.ptr, FF_MPV_QSCALE_TYPE_MPEG1); |
| 662 | } | 661 | } |
| 663 | 662 | ||
| 664 | if (s->last_pic_ptr || s->low_delay) { | 663 | if (s->last_pic.ptr || s->low_delay) { |
| 665 | if ( pict->format == AV_PIX_FMT_YUV420P | 664 | if ( pict->format == AV_PIX_FMT_YUV420P |
| 666 | && (s->codec_tag == AV_RL32("GEOV") || s->codec_tag == AV_RL32("GEOX"))) { | 665 | && (s->codec_tag == AV_RL32("GEOV") || s->codec_tag == AV_RL32("GEOX"))) { |
| 667 | for (int p = 0; p < 3; p++) { | 666 | for (int p = 0; p < 3; p++) { |
| @@ -750,12 +750,12 @@ static inline void set_one_direct_mv(MpegEncContext *s, const MPVPicture *p, int · 749 unmodified lines | |||
| 750 | static int set_direct_mv(MpegEncContext *s) | 750 | static int set_direct_mv(MpegEncContext *s) |
| 751 | { | 751 | { |
| 752 | const int mb_index = s->mb_x + s->mb_y * s->mb_stride; | 752 | const int mb_index = s->mb_x + s->mb_y * s->mb_stride; |
| 753 | const MPVPicture *p = &s->next_pic; | 753 | const MPVPicture *p = s->next_pic.ptr; |
| 754 | int colocated_mb_type = p->mb_type[mb_index]; | 754 | int colocated_mb_type = p->mb_type[mb_index]; |
| 755 | int i; | 755 | int i; |
| 756 | 756 | ||
| 757 | if (s->codec_tag == AV_RL32("U263") && p->f->pict_type == AV_PICTURE_TYPE_I) { | 757 | if (s->codec_tag == AV_RL32("U263") && p->f->pict_type == AV_PICTURE_TYPE_I) { |
| 758 | p = &s->last_pic; | 758 | p = s->last_pic.ptr; |
| 759 | colocated_mb_type = p->mb_type[mb_index]; | 759 | colocated_mb_type = p->mb_type[mb_index]; |
| 760 | } | 760 | } |
| 761 | 761 | ||
| @@ -1292,7 +1292,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) · 1291 unmodified lines | |||
| 1292 | return ret; | 1292 | return ret; |
| 1293 | 1293 | ||
| 1294 | if (s->picture_structure != PICT_FRAME) { | 1294 | if (s->picture_structure != PICT_FRAME) { |
| 1295 | s->cur_pic_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * | 1295 | s->cur_pic.ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * |
| 1296 | (s->picture_structure == PICT_TOP_FIELD); | 1296 | (s->picture_structure == PICT_TOP_FIELD); |
| 1297 | 1297 | ||
| 1298 | for (int i = 0; i < 3; i++) { | 1298 | for (int i = 0; i < 3; i++) { |
| @@ -1309,19 +1309,19 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) · 10 unmodified lines | |||
| 1309 | ff_mpeg_er_frame_start(s); | 1309 | ff_mpeg_er_frame_start(s); |
| 1310 | 1310 | ||
| 1311 | /* first check if we must repeat the frame */ | 1311 | /* first check if we must repeat the frame */ |
| 1312 | s->cur_pic_ptr->f->repeat_pict = 0; | 1312 | s->cur_pic.ptr->f->repeat_pict = 0; |
| 1313 | if (s->repeat_first_field) { | 1313 | if (s->repeat_first_field) { |
| 1314 | if (s->progressive_sequence) { | 1314 | if (s->progressive_sequence) { |
| 1315 | if (s->top_field_first) | 1315 | if (s->top_field_first) |
| 1316 | s->cur_pic_ptr->f->repeat_pict = 4; | 1316 | s->cur_pic.ptr->f->repeat_pict = 4; |
| 1317 | else | 1317 | else |
| 1318 | s->cur_pic_ptr->f->repeat_pict = 2; | 1318 | s->cur_pic.ptr->f->repeat_pict = 2; |
| 1319 | } else if (s->progressive_frame) { | 1319 | } else if (s->progressive_frame) { |
| 1320 | s->cur_pic_ptr->f->repeat_pict = 1; | 1320 | s->cur_pic.ptr->f->repeat_pict = 1; |
| 1321 | } | 1321 | } |
| 1322 | } | 1322 | } |
| 1323 | 1323 | ||
| 1324 | ret = ff_frame_new_side_data(s->avctx, s->cur_pic_ptr->f, | 1324 | ret = ff_frame_new_side_data(s->avctx, s->cur_pic.ptr->f, |
| 1325 | AV_FRAME_DATA_PANSCAN, sizeof(s1->pan_scan), | 1325 | AV_FRAME_DATA_PANSCAN, sizeof(s1->pan_scan), |
| 1326 | &pan_scan); | 1326 | &pan_scan); |
| 1327 | if (ret < 0) | 1327 | if (ret < 0) |
| @@ -1331,14 +1331,14 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) · 3 unmodified lines | |||
| 1331 | 1331 | ||
| 1332 | if (s1->a53_buf_ref) { | 1332 | if (s1->a53_buf_ref) { |
| 1333 | ret = ff_frame_new_side_data_from_buf( | 1333 | ret = ff_frame_new_side_data_from_buf( |
| 1334 | s->avctx, s->cur_pic_ptr->f, AV_FRAME_DATA_A53_CC, | 1334 | s->avctx, s->cur_pic.ptr->f, AV_FRAME_DATA_A53_CC, |
| 1335 | &s1->a53_buf_ref, NULL); | 1335 | &s1->a53_buf_ref, NULL); |
| 1336 | if (ret < 0) | 1336 | if (ret < 0) |
| 1337 | return ret; | 1337 | return ret; |
| 1338 | } | 1338 | } |
| 1339 | 1339 | ||
| 1340 | if (s1->has_stereo3d) { | 1340 | if (s1->has_stereo3d) { |
| 1341 | AVStereo3D *stereo = av_stereo3d_create_side_data(s->cur_pic_ptr->f); | 1341 | AVStereo3D *stereo = av_stereo3d_create_side_data(s->cur_pic.ptr->f); |
| 1342 | if (!stereo) | 1342 | if (!stereo) |
| 1343 | return AVERROR(ENOMEM); | 1343 | return AVERROR(ENOMEM); |
| 1344 | 1344 | ||
| @@ -1348,7 +1348,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) · 3 unmodified lines | |||
| 1348 | 1348 | ||
| 1349 | if (s1->has_afd) { | 1349 | if (s1->has_afd) { |
| 1350 | AVFrameSideData *sd; | 1350 | AVFrameSideData *sd; |
| 1351 | ret = ff_frame_new_side_data(s->avctx, s->cur_pic_ptr->f, | 1351 | ret = ff_frame_new_side_data(s->avctx, s->cur_pic.ptr->f, |
| 1352 | AV_FRAME_DATA_AFD, 1, &sd); | 1352 | AV_FRAME_DATA_AFD, 1, &sd); |
| 1353 | if (ret < 0) | 1353 | if (ret < 0) |
| 1354 | return ret; | 1354 | return ret; |
| @@ -1360,7 +1360,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) · 5 unmodified lines | |||
| 1360 | if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME)) | 1360 | if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME)) |
| 1361 | ff_thread_finish_setup(avctx); | 1361 | ff_thread_finish_setup(avctx); |
| 1362 | } else { // second field | 1362 | } else { // second field |
| 1363 | if (!s->cur_pic_ptr) { | 1363 | if (!s->cur_pic.ptr) { |
| 1364 | av_log(s->avctx, AV_LOG_ERROR, "first field missing\n"); | 1364 | av_log(s->avctx, AV_LOG_ERROR, "first field missing\n"); |
| 1365 | return AVERROR_INVALIDDATA; | 1365 | return AVERROR_INVALIDDATA; |
| 1366 | } | 1366 | } |
| @@ -1377,10 +1377,10 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) · 10 unmodified lines | |||
| 1377 | return ret; | 1377 | return ret; |
| 1378 | 1378 | ||
| 1379 | for (int i = 0; i < 3; i++) { | 1379 | for (int i = 0; i < 3; i++) { |
| 1380 | s->cur_pic.data[i] = s->cur_pic_ptr->f->data[i]; | 1380 | s->cur_pic.data[i] = s->cur_pic.ptr->f->data[i]; |
| 1381 | if (s->picture_structure == PICT_BOTTOM_FIELD) | 1381 | if (s->picture_structure == PICT_BOTTOM_FIELD) |
| 1382 | s->cur_pic.data[i] += | 1382 | s->cur_pic.data[i] += |
| 1383 | s->cur_pic_ptr->f->linesize[i]; | 1383 | s->cur_pic.ptr->f->linesize[i]; |
| 1384 | } | 1384 | } |
| 1385 | } | 1385 | } |
| 1386 | 1386 | ||
| @@ -1735,7 +1735,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output) · 348 unmodified lines | |||
| 1735 | Mpeg1Context *s1 = avctx->priv_data; | 1735 | Mpeg1Context *s1 = avctx->priv_data; |
| 1736 | MpegEncContext *s = &s1->mpeg_enc_ctx; | 1736 | MpegEncContext *s = &s1->mpeg_enc_ctx; |
| 1737 | 1737 | ||
| 1738 | if (!s->context_initialized || !s->cur_pic_ptr) | 1738 | if (!s->context_initialized || !s->cur_pic.ptr) |
| 1739 | return 0; | 1739 | return 0; |
| 1740 | 1740 | ||
| 1741 | if (s->avctx->hwaccel) { | 1741 | if (s->avctx->hwaccel) { |
| @@ -1756,20 +1756,20 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output) · 14 unmodified lines | |||
| 1756 | ff_mpv_frame_end(s); | 1756 | ff_mpv_frame_end(s); |
| 1757 | 1757 | ||
| 1758 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { | 1758 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { |
| 1759 | int ret = av_frame_ref(pict, s->cur_pic_ptr->f); | 1759 | int ret = av_frame_ref(pict, s->cur_pic.ptr->f); |
| 1760 | if (ret < 0) | 1760 | if (ret < 0) |
| 1761 | return ret; | 1761 | return ret; |
| 1762 | ff_print_debug_info(s, s->cur_pic_ptr, pict); | 1762 | ff_print_debug_info(s, s->cur_pic.ptr, pict); |
| 1763 | ff_mpv_export_qp_table(s, pict, s->cur_pic_ptr, FF_MPV_QSCALE_TYPE_MPEG2); | 1763 | ff_mpv_export_qp_table(s, pict, s->cur_pic.ptr, FF_MPV_QSCALE_TYPE_MPEG2); |
| 1764 | *got_output = 1; | 1764 | *got_output = 1; |
| 1765 | } else { | 1765 | } else { |
| 1766 | /* latency of 1 frame for I- and P-frames */ | 1766 | /* latency of 1 frame for I- and P-frames */ |
| 1767 | if (s->last_pic_ptr && !s->last_pic_ptr->dummy) { | 1767 | if (s->last_pic.ptr && !s->last_pic.ptr->dummy) { |
| 1768 | int ret = av_frame_ref(pict, s->last_pic_ptr->f); | 1768 | int ret = av_frame_ref(pict, s->last_pic.ptr->f); |
| 1769 | if (ret < 0) | 1769 | if (ret < 0) |
| 1770 | return ret; | 1770 | return ret; |
| 1771 | ff_print_debug_info(s, s->last_pic_ptr, pict); | 1771 | ff_print_debug_info(s, s->last_pic.ptr, pict); |
| 1772 | ff_mpv_export_qp_table(s, pict, s->last_pic_ptr, FF_MPV_QSCALE_TYPE_MPEG2); | 1772 | ff_mpv_export_qp_table(s, pict, s->last_pic.ptr, FF_MPV_QSCALE_TYPE_MPEG2); |
| 1773 | *got_output = 1; | 1773 | *got_output = 1; |
| 1774 | } | 1774 | } |
| 1775 | } | 1775 | } |
| @@ -2405,7 +2405,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, · 629 unmodified lines | |||
| 2405 | return AVERROR_INVALIDDATA; | 2405 | return AVERROR_INVALIDDATA; |
| 2406 | } | 2406 | } |
| 2407 | 2407 | ||
| 2408 | if (!s2->last_pic_ptr) { | 2408 | if (!s2->last_pic.ptr) { |
| 2409 | /* Skip B-frames if we do not have reference frames and | 2409 | /* Skip B-frames if we do not have reference frames and |
| 2410 | * GOP is not closed. */ | 2410 | * GOP is not closed. */ |
| 2411 | if (s2->pict_type == AV_PICTURE_TYPE_B) { | 2411 | if (s2->pict_type == AV_PICTURE_TYPE_B) { |
| @@ -2419,7 +2419,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, · 7 unmodified lines | |||
| 2419 | } | 2419 | } |
| 2420 | if (s2->pict_type == AV_PICTURE_TYPE_I || (s2->avctx->flags2 & AV_CODEC_FLAG2_SHOW_ALL)) | 2420 | if (s2->pict_type == AV_PICTURE_TYPE_I || (s2->avctx->flags2 & AV_CODEC_FLAG2_SHOW_ALL)) |
| 2421 | s->sync = 1; | 2421 | s->sync = 1; |
| 2422 | if (!s2->next_pic_ptr) { | 2422 | if (!s2->next_pic.ptr) { |
| 2423 | /* Skip P-frames if we do not have a reference frame or | 2423 | /* Skip P-frames if we do not have a reference frame or |
| 2424 | * we have an invalid header. */ | 2424 | * we have an invalid header. */ |
| 2425 | if (s2->pict_type == AV_PICTURE_TYPE_P && !s->sync) { | 2425 | if (s2->pict_type == AV_PICTURE_TYPE_P && !s->sync) { |
| @@ -2460,7 +2460,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, · 34 unmodified lines | |||
| 2460 | if ((ret = mpeg_field_start(s2, buf, buf_size)) < 0) | 2460 | if ((ret = mpeg_field_start(s2, buf, buf_size)) < 0) |
| 2461 | return ret; | 2461 | return ret; |
| 2462 | } | 2462 | } |
| 2463 | if (!s2->cur_pic_ptr) { | 2463 | if (!s2->cur_pic.ptr) { |
| 2464 | av_log(avctx, AV_LOG_ERROR, | 2464 | av_log(avctx, AV_LOG_ERROR, |
| 2465 | "current_picture not initialized\n"); | 2465 | "current_picture not initialized\n"); |
| 2466 | return AVERROR_INVALIDDATA; | 2466 | return AVERROR_INVALIDDATA; |
| @@ -2524,12 +2524,12 @@ static int mpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture, · 57 unmodified lines | |||
| 2524 | 2524 | ||
| 2525 | if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) { | 2525 | if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) { |
| 2526 | /* special case for last picture */ | 2526 | /* special case for last picture */ |
| 2527 | if (s2->low_delay == 0 && s2->next_pic_ptr) { | 2527 | if (s2->low_delay == 0 && s2->next_pic.ptr) { |
| 2528 | int ret = av_frame_ref(picture, s2->next_pic_ptr->f); | 2528 | int ret = av_frame_ref(picture, s2->next_pic.ptr->f); |
| 2529 | if (ret < 0) | 2529 | if (ret < 0) |
| 2530 | return ret; | 2530 | return ret; |
| 2531 | 2531 | ||
| 2532 | s2->next_pic_ptr = NULL; | 2532 | s2->next_pic.ptr = NULL; |
| 2533 | 2533 | ||
| 2534 | *got_output = 1; | 2534 | *got_output = 1; |
| 2535 | } | 2535 | } |
| @@ -2552,14 +2552,14 @@ static int mpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture, · 16 unmodified lines | |||
| 2552 | } | 2552 | } |
| 2553 | s->extradata_decoded = 1; | 2553 | s->extradata_decoded = 1; |
| 2554 | if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) { | 2554 | if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) { |
| 2555 | s2->cur_pic_ptr = NULL; | 2555 | s2->cur_pic.ptr = NULL; |
| 2556 | return ret; | 2556 | return ret; |
| 2557 | } | 2557 | } |
| 2558 | } | 2558 | } |
| 2559 | 2559 | ||
| 2560 | ret = decode_chunks(avctx, picture, got_output, buf, buf_size); | 2560 | ret = decode_chunks(avctx, picture, got_output, buf, buf_size); |
| 2561 | if (ret<0 || *got_output) { | 2561 | if (ret<0 || *got_output) { |
| 2562 | s2->cur_pic_ptr = NULL; | 2562 | s2->cur_pic.ptr = NULL; |
| 2563 | 2563 | ||
| 2564 | if (s->timecode_frame_start != -1 && *got_output) { | 2564 | if (s->timecode_frame_start != -1 && *got_output) { |
| 2565 | char tcbuf[AV_TIMECODE_STR_SIZE]; | 2565 | char tcbuf[AV_TIMECODE_STR_SIZE]; |
| @@ -290,7 +290,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) · 289 unmodified lines | |||
| 290 | AVRational aspect_ratio = s->avctx->sample_aspect_ratio; | 290 | AVRational aspect_ratio = s->avctx->sample_aspect_ratio; |
| 291 | int aspect_ratio_info; | 291 | int aspect_ratio_info; |
| 292 | 292 | ||
| 293 | if (!(s->cur_pic.f->flags & AV_FRAME_FLAG_KEY)) | 293 | if (!(s->cur_pic.ptr->f->flags & AV_FRAME_FLAG_KEY)) |
| 294 | return; | 294 | return; |
| 295 | 295 | ||
| 296 | if (aspect_ratio.num == 0 || aspect_ratio.den == 0) | 296 | if (aspect_ratio.num == 0 || aspect_ratio.den == 0) |
| @@ -382,7 +382,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) · 85 unmodified lines | |||
| 382 | put_bits(&s->pb, 2, mpeg12->frame_rate_ext.num-1); // frame_rate_ext_n | 382 | put_bits(&s->pb, 2, mpeg12->frame_rate_ext.num-1); // frame_rate_ext_n |
| 383 | put_bits(&s->pb, 5, mpeg12->frame_rate_ext.den-1); // frame_rate_ext_d | 383 | put_bits(&s->pb, 5, mpeg12->frame_rate_ext.den-1); // frame_rate_ext_d |
| 384 | 384 | ||
| 385 | side_data = av_frame_get_side_data(s->cur_pic_ptr->f, AV_FRAME_DATA_PANSCAN); | 385 | side_data = av_frame_get_side_data(s->cur_pic.ptr->f, AV_FRAME_DATA_PANSCAN); |
| 386 | if (side_data) { | 386 | if (side_data) { |
| 387 | const AVPanScan *pan_scan = (AVPanScan *)side_data->data; | 387 | const AVPanScan *pan_scan = (AVPanScan *)side_data->data; |
| 388 | if (pan_scan->width && pan_scan->height) { | 388 | if (pan_scan->width && pan_scan->height) { |
| @@ -419,10 +419,10 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) · 30 unmodified lines | |||
| 419 | /* time code: we must convert from the real frame rate to a | 419 | /* time code: we must convert from the real frame rate to a |
| 420 | * fake MPEG frame rate in case of low frame rate */ | 420 | * fake MPEG frame rate in case of low frame rate */ |
| 421 | fps = (framerate.num + framerate.den / 2) / framerate.den; | 421 | fps = (framerate.num + framerate.den / 2) / framerate.den; |
| 422 | time_code = s->cur_pic_ptr->coded_picture_number + | 422 | time_code = s->cur_pic.ptr->coded_picture_number + |
| 423 | mpeg12->timecode_frame_start; | 423 | mpeg12->timecode_frame_start; |
| 424 | 424 | ||
| 425 | mpeg12->gop_picture_number = s->cur_pic_ptr->coded_picture_number; | 425 | mpeg12->gop_picture_number = s->cur_pic.ptr->coded_picture_number; |
| 426 | 426 | ||
| 427 | av_assert0(mpeg12->drop_frame_timecode == !!(mpeg12->tc.flags & AV_TIMECODE_FLAG_DROPFRAME)); | 427 | av_assert0(mpeg12->drop_frame_timecode == !!(mpeg12->tc.flags & AV_TIMECODE_FLAG_DROPFRAME)); |
| 428 | if (mpeg12->drop_frame_timecode) | 428 | if (mpeg12->drop_frame_timecode) |
| @@ -530,7 +530,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s) · 101 unmodified lines | |||
| 530 | if (s->progressive_sequence) | 530 | if (s->progressive_sequence) |
| 531 | put_bits(&s->pb, 1, 0); /* no repeat */ | 531 | put_bits(&s->pb, 1, 0); /* no repeat */ |
| 532 | else | 532 | else |
| 533 | put_bits(&s->pb, 1, !!(s->cur_pic_ptr->f->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)); | 533 | put_bits(&s->pb, 1, !!(s->cur_pic.ptr->f->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)); |
| 534 | /* XXX: optimize the generation of this flag with entropy measures */ | 534 | /* XXX: optimize the generation of this flag with entropy measures */ |
| 535 | s->frame_pred_frame_dct = s->progressive_sequence; | 535 | s->frame_pred_frame_dct = s->progressive_sequence; |
| 536 | 536 | ||
| @@ -554,7 +554,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s) · 17 unmodified lines | |||
| 554 | for (i = 0; i < sizeof(svcd_scan_offset_placeholder); i++) | 554 | for (i = 0; i < sizeof(svcd_scan_offset_placeholder); i++) |
| 555 | put_bits(&s->pb, 8, svcd_scan_offset_placeholder[i]); | 555 | put_bits(&s->pb, 8, svcd_scan_offset_placeholder[i]); |
| 556 | } | 556 | } |
| 557 | side_data = av_frame_get_side_data(s->cur_pic_ptr->f, | 557 | side_data = av_frame_get_side_data(s->cur_pic.ptr->f, |
| 558 | AV_FRAME_DATA_STEREO3D); | 558 | AV_FRAME_DATA_STEREO3D); |
| 559 | if (side_data) { | 559 | if (side_data) { |
| 560 | const AVStereo3D *stereo = (AVStereo3D *)side_data->data; | 560 | const AVStereo3D *stereo = (AVStereo3D *)side_data->data; |
| @@ -594,7 +594,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s) · 33 unmodified lines | |||
| 594 | } | 594 | } |
| 595 | 595 | ||
| 596 | if (CONFIG_MPEG2VIDEO_ENCODER && mpeg12->a53_cc) { | 596 | if (CONFIG_MPEG2VIDEO_ENCODER && mpeg12->a53_cc) { |
| 597 | side_data = av_frame_get_side_data(s->cur_pic_ptr->f, | 597 | side_data = av_frame_get_side_data(s->cur_pic.ptr->f, |
| 598 | AV_FRAME_DATA_A53_CC); | 598 | AV_FRAME_DATA_A53_CC); |
| 599 | if (side_data) { | 599 | if (side_data) { |
| 600 | if (side_data->size <= A53_MAX_CC_COUNT * 3 && side_data->size % 3 == 0) { | 600 | if (side_data->size <= A53_MAX_CC_COUNT * 3 && side_data->size % 3 == 0) { |
| @@ -1813,7 +1813,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 1812 unmodified lines | |||
| 1813 | s->last_mv[i][1][1] = 0; | 1813 | s->last_mv[i][1][1] = 0; |
| 1814 | } | 1814 | } |
| 1815 | 1815 | ||
| 1816 | ff_thread_await_progress(&s->next_pic_ptr->tf, s->mb_y, 0); | 1816 | ff_thread_await_progress(&s->next_pic.ptr->tf, s->mb_y, 0); |
| 1817 | } | 1817 | } |
| 1818 | 1818 | ||
| 1819 | /* if we skipped it in the future P-frame than skip it now too */ | 1819 | /* if we skipped it in the future P-frame than skip it now too */ |
| @@ -2018,7 +2018,7 @@ end: · 198 unmodified lines | |||
| 2018 | 2018 | ||
| 2019 | if (s->pict_type == AV_PICTURE_TYPE_B) { | 2019 | if (s->pict_type == AV_PICTURE_TYPE_B) { |
| 2020 | const int delta = s->mb_x + 1 == s->mb_width ? 2 : 1; | 2020 | const int delta = s->mb_x + 1 == s->mb_width ? 2 : 1; |
| 2021 | ff_thread_await_progress(&s->next_pic_ptr->tf, | 2021 | ff_thread_await_progress(&s->next_pic.ptr->tf, |
| 2022 | (s->mb_x + delta >= s->mb_width) | 2022 | (s->mb_x + delta >= s->mb_width) |
| 2023 | ? FFMIN(s->mb_y + 1, s->mb_height - 1) | 2023 | ? FFMIN(s->mb_y + 1, s->mb_height - 1) |
| 2024 | : s->mb_y, 0); | 2024 | : s->mb_y, 0); |
| @@ -888,7 +888,7 @@ static void mpeg4_encode_gop_header(MpegEncContext *s) · 887 unmodified lines | |||
| 888 | put_bits(&s->pb, 16, 0); | 888 | put_bits(&s->pb, 16, 0); |
| 889 | put_bits(&s->pb, 16, GOP_STARTCODE); | 889 | put_bits(&s->pb, 16, GOP_STARTCODE); |
| 890 | 890 | ||
| 891 | time = s->cur_pic_ptr->f->pts; | 891 | time = s->cur_pic.ptr->f->pts; |
| 892 | if (s->reordered_input_picture[1]) | 892 | if (s->reordered_input_picture[1]) |
| 893 | time = FFMIN(time, s->reordered_input_picture[1]->f->pts); | 893 | time = FFMIN(time, s->reordered_input_picture[1]->f->pts); |
| 894 | time = time * s->avctx->time_base.num; | 894 | time = time * s->avctx->time_base.num; |
| @@ -1100,7 +1100,7 @@ int ff_mpeg4_encode_picture_header(MpegEncContext *s) · 205 unmodified lines | |||
| 1100 | } | 1100 | } |
| 1101 | put_bits(&s->pb, 3, 0); /* intra dc VLC threshold */ | 1101 | put_bits(&s->pb, 3, 0); /* intra dc VLC threshold */ |
| 1102 | if (!s->progressive_sequence) { | 1102 | if (!s->progressive_sequence) { |
| 1103 | put_bits(&s->pb, 1, !!(s->cur_pic_ptr->f->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)); | 1103 | put_bits(&s->pb, 1, !!(s->cur_pic.ptr->f->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)); |
| 1104 | put_bits(&s->pb, 1, s->alternate_scan); | 1104 | put_bits(&s->pb, 1, s->alternate_scan); |
| 1105 | } | 1105 | } |
| 1106 | // FIXME sprite stuff | 1106 | // FIXME sprite stuff |
| @@ -49,9 +49,9 @@ void ff_mpeg_er_frame_start(MpegEncContext *s) · 48 unmodified lines | |||
| 49 | { | 49 | { |
| 50 | ERContext *er = &s->er; | 50 | ERContext *er = &s->er; |
| 51 | 51 | ||
| 52 | set_erpic(&er->cur_pic, s->cur_pic_ptr); | 52 | set_erpic(&er->cur_pic, s->cur_pic.ptr); |
| 53 | set_erpic(&er->next_pic, s->next_pic_ptr); | 53 | set_erpic(&er->next_pic, s->next_pic.ptr); |
| 54 | set_erpic(&er->last_pic, s->last_pic_ptr); | 54 | set_erpic(&er->last_pic, s->last_pic.ptr); |
| 55 | 55 | ||
| 56 | er->pp_time = s->pp_time; | 56 | er->pp_time = s->pp_time; |
| 57 | er->pb_time = s->pb_time; | 57 | er->pb_time = s->pb_time; |
| @@ -45,6 +45,45 @@ static void av_noinline free_picture_tables(MPVPicture *pic) · 44 unmodified lines | |||
| 45 | pic->mb_height = 0; | 45 | pic->mb_height = 0; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void ff_mpv_unref_picture(MPVWorkPicture *pic) | ||
| 49 | { | ||
| 50 | if (pic->ptr) | ||
| 51 | ff_mpeg_unref_picture(pic->ptr); | ||
| 52 | memset(pic, 0, sizeof(*pic)); | ||
| 53 | } | ||
| 54 | |||
| 55 | static void set_workpic_from_pic(MPVWorkPicture *wpic, const MPVPicture *pic) | ||
| 56 | { | ||
| 57 | for (int i = 0; i < MPV_MAX_PLANES; i++) { | ||
| 58 | wpic->data[i] = pic->f->data[i]; | ||
| 59 | wpic->linesize[i] = pic->f->linesize[i]; | ||
| 60 | } | ||
| 61 | wpic->qscale_table = pic->qscale_table; | ||
| 62 | wpic->mb_type = pic->mb_type; | ||
| 63 | wpic->mbskip_table = pic->mbskip_table; | ||
| 64 | |||
| 65 | for (int i = 0; i < 2; i++) { | ||
| 66 | wpic->motion_val[i] = pic->motion_val[i]; | ||
| 67 | wpic->ref_index[i] = pic->ref_index[i]; | ||
| 68 | } | ||
| 69 | wpic->reference = pic->reference; | ||
| 70 | } | ||
| 71 | |||
| 72 | void ff_mpv_replace_picture(MPVWorkPicture *dst, const MPVWorkPicture *src) | ||
| 73 | { | ||
| 74 | memcpy(dst, src, sizeof(*dst)); | ||
| 75 | } | ||
| 76 | |||
| 77 | void ff_mpv_workpic_from_pic(MPVWorkPicture *wpic, MPVPicture *pic) | ||
| 78 | { | ||
| 79 | if (!pic) { | ||
| 80 | memset(wpic, 0, sizeof(*wpic)); | ||
| 81 | return; | ||
| 82 | } | ||
| 83 | wpic->ptr = pic; | ||
| 84 | set_workpic_from_pic(wpic, pic); | ||
| 85 | } | ||
| 86 | |||
| 48 | int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, | 87 | int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, |
| 49 | ScratchpadContext *sc, int linesize) | 88 | ScratchpadContext *sc, int linesize) |
| 50 | { | 89 | { |
| @@ -143,17 +182,13 @@ static int alloc_picture_tables(BufferPoolContext *pools, MPVPicture *pic, · 92 unmodified lines | |||
| 143 | return 0; | 182 | return 0; |
| 144 | } | 183 | } |
| 145 | 184 | ||
| 146 | int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVPicture *pic, | 185 | int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVWorkPicture *wpic, |
| 147 | MotionEstContext *me, ScratchpadContext *sc, | 186 | MotionEstContext *me, ScratchpadContext *sc, |
| 148 | BufferPoolContext *pools, int mb_height) | 187 | BufferPoolContext *pools, int mb_height) |
| 149 | { | 188 | { |
| 189 | MPVPicture *pic = wpic->ptr; | ||
| 150 | int ret; | 190 | int ret; |
| 151 | 191 | ||
| 152 | for (int i = 0; i < MPV_MAX_PLANES; i++) { | ||
| 153 | pic->data[i] = pic->f->data[i]; | ||
| 154 | pic->linesize[i] = pic->f->linesize[i]; | ||
| 155 | } | ||
| 156 | |||
| 157 | ret = ff_mpeg_framesize_alloc(avctx, me, sc, | 192 | ret = ff_mpeg_framesize_alloc(avctx, me, sc, |
| 158 | pic->f->linesize[0]); | 193 | pic->f->linesize[0]); |
| 159 | if (ret < 0) | 194 | if (ret < 0) |
| @@ -170,6 +205,7 @@ int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVPicture *pic, · 10 unmodified lines | |||
| 170 | for (int i = 0; i < 2; i++) | 205 | for (int i = 0; i < 2; i++) |
| 171 | pic->motion_val[i] = pic->motion_val_base[i] + 4; | 206 | pic->motion_val[i] = pic->motion_val_base[i] + 4; |
| 172 | } | 207 | } |
| 208 | set_workpic_from_pic(wpic, pic); | ||
| 173 | 209 | ||
| 174 | return 0; | 210 | return 0; |
| 175 | fail: | 211 | fail: |
| @@ -190,9 +226,6 @@ void ff_mpeg_unref_picture(MPVPicture *pic) · 14 unmodified lines | |||
| 190 | 226 | ||
| 191 | free_picture_tables(pic); | 227 | free_picture_tables(pic); |
| 192 | 228 | ||
| 193 | memset(pic->data, 0, sizeof(pic->data)); | ||
| 194 | memset(pic->linesize, 0, sizeof(pic->linesize)); | ||
| 195 | |||
| 196 | pic->dummy = 0; | 229 | pic->dummy = 0; |
| 197 | 230 | ||
| 198 | pic->field_picture = 0; | 231 | pic->field_picture = 0; |
| @@ -236,11 +269,6 @@ int ff_mpeg_ref_picture(MPVPicture *dst, MPVPicture *src) · 37 unmodified lines | |||
| 236 | if (ret < 0) | 269 | if (ret < 0) |
| 237 | goto fail; | 270 | goto fail; |
| 238 | 271 | ||
| 239 | for (int i = 0; i < MPV_MAX_PLANES; i++) { | ||
| 240 | dst->data[i] = src->data[i]; | ||
| 241 | dst->linesize[i] = src->linesize[i]; | ||
| 242 | } | ||
| 243 | |||
| 244 | update_picture_tables(dst, src); | 272 | update_picture_tables(dst, src); |
| 245 | 273 | ||
| 246 | ff_refstruct_replace(&dst->hwaccel_picture_private, | 274 | ff_refstruct_replace(&dst->hwaccel_picture_private, |
| @@ -58,9 +58,6 @@ typedef struct MPVPicture { · 57 unmodified lines | |||
| 58 | struct AVFrame *f; | 58 | struct AVFrame *f; |
| 59 | ThreadFrame tf; | 59 | ThreadFrame tf; |
| 60 | 60 | ||
| 61 | uint8_t *data[MPV_MAX_PLANES]; | ||
| 62 | ptrdiff_t linesize[MPV_MAX_PLANES]; | ||
| 63 | |||
| 64 | int8_t *qscale_table_base; | 61 | int8_t *qscale_table_base; |
| 65 | int8_t *qscale_table; | 62 | int8_t *qscale_table; |
| 66 | 63 | ||
| @@ -93,10 +90,30 @@ typedef struct MPVPicture { · 26 unmodified lines | |||
| 93 | int coded_picture_number; | 90 | int coded_picture_number; |
| 94 | } MPVPicture; | 91 | } MPVPicture; |
| 95 | 92 | ||
| 93 | typedef struct MPVWorkPicture { | ||
| 94 | uint8_t *data[MPV_MAX_PLANES]; | ||
| 95 | ptrdiff_t linesize[MPV_MAX_PLANES]; | ||
| 96 | |||
| 97 | MPVPicture *ptr; | ||
| 98 | |||
| 99 | int8_t *qscale_table; | ||
| 100 | |||
| 101 | int16_t (*motion_val[2])[2]; | ||
| 102 | |||
| 103 | uint32_t *mb_type; ///< types and macros are defined in mpegutils.h | ||
| 104 | |||
| 105 | uint8_t *mbskip_table; | ||
| 106 | |||
| 107 | int8_t *ref_index[2]; | ||
| 108 | |||
| 109 | int reference; | ||
| 110 | } MPVWorkPicture; | ||
| 111 | |||
| 96 | /** | 112 | /** |
| 97 | * Allocate an MPVPicture's accessories, but not the AVFrame's buffer itself. | 113 | * Allocate an MPVPicture's accessories (but not the AVFrame's buffer itself) |
| 114 | * and set the MPVWorkPicture's fields. | ||
| 98 | */ | 115 | */ |
| 99 | int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVPicture *pic, | 116 | int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVWorkPicture *pic, |
| 100 | MotionEstContext *me, ScratchpadContext *sc, | 117 | MotionEstContext *me, ScratchpadContext *sc, |
| 101 | BufferPoolContext *pools, int mb_height); | 118 | BufferPoolContext *pools, int mb_height); |
| 102 | 119 | ||
| @@ -113,6 +130,9 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, · 10 unmodified lines | |||
| 113 | ScratchpadContext *sc, int linesize); | 130 | ScratchpadContext *sc, int linesize); |
| 114 | 131 | ||
| 115 | int ff_mpeg_ref_picture(MPVPicture *dst, MPVPicture *src); | 132 | int ff_mpeg_ref_picture(MPVPicture *dst, MPVPicture *src); |
| 133 | void ff_mpv_unref_picture(MPVWorkPicture *pic); | ||
| 134 | void ff_mpv_workpic_from_pic(MPVWorkPicture *wpic, MPVPicture *pic); | ||
| 135 | void ff_mpv_replace_picture(MPVWorkPicture *dst, const MPVWorkPicture *src); | ||
| 116 | void ff_mpeg_unref_picture(MPVPicture *picture); | 136 | void ff_mpeg_unref_picture(MPVPicture *picture); |
| 117 | 137 | ||
| 118 | void ff_mpv_picture_free(MPVPicture *pic); | 138 | void ff_mpv_picture_free(MPVPicture *pic); |
| @@ -763,11 +763,6 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) · 762 unmodified lines | |||
| 763 | goto fail_nomem; | 763 | goto fail_nomem; |
| 764 | } | 764 | } |
| 765 | 765 | ||
| 766 | if (!(s->next_pic.f = av_frame_alloc()) || | ||
| 767 | !(s->last_pic.f = av_frame_alloc()) || | ||
| 768 | !(s->cur_pic.f = av_frame_alloc())) | ||
| 769 | goto fail_nomem; | ||
| 770 | |||
| 771 | if ((ret = ff_mpv_init_context_frame(s))) | 766 | if ((ret = ff_mpv_init_context_frame(s))) |
| 772 | goto fail; | 767 | goto fail; |
| 773 | 768 | ||
| @@ -840,15 +835,9 @@ void ff_mpv_common_end(MpegEncContext *s) · 66 unmodified lines | |||
| 840 | ff_mpv_picture_free(&s->picture[i]); | 835 | ff_mpv_picture_free(&s->picture[i]); |
| 841 | } | 836 | } |
| 842 | av_freep(&s->picture); | 837 | av_freep(&s->picture); |
| 843 | ff_mpv_picture_free(&s->last_pic); | ||
| 844 | ff_mpv_picture_free(&s->cur_pic); | ||
| 845 | ff_mpv_picture_free(&s->next_pic); | ||
| 846 | 838 | ||
| 847 | s->context_initialized = 0; | 839 | s->context_initialized = 0; |
| 848 | s->context_reinit = 0; | 840 | s->context_reinit = 0; |
| 849 | s->last_pic_ptr = | ||
| 850 | s->next_pic_ptr = | ||
| 851 | s->cur_pic_ptr = NULL; | ||
| 852 | s->linesize = s->uvlinesize = 0; | 841 | s->linesize = s->uvlinesize = 0; |
| 853 | } | 842 | } |
| 854 | 843 | ||
| @@ -156,13 +156,13 @@ typedef struct MpegEncContext { · 155 unmodified lines | |||
| 156 | * copy of the previous picture structure. | 156 | * copy of the previous picture structure. |
| 157 | * note, linesize & data, might not match the previous picture (for field pictures) | 157 | * note, linesize & data, might not match the previous picture (for field pictures) |
| 158 | */ | 158 | */ |
| 159 | MPVPicture last_pic; | 159 | MPVWorkPicture last_pic; |
| 160 | 160 | ||
| 161 | /** | 161 | /** |
| 162 | * copy of the next picture structure. | 162 | * copy of the next picture structure. |
| 163 | * note, linesize & data, might not match the next picture (for field pictures) | 163 | * note, linesize & data, might not match the next picture (for field pictures) |
| 164 | */ | 164 | */ |
| 165 | MPVPicture next_pic; | 165 | MPVWorkPicture next_pic; |
| 166 | 166 | ||
| 167 | /** | 167 | /** |
| 168 | * Reference to the source picture for encoding. | 168 | * Reference to the source picture for encoding. |
| @@ -174,11 +174,8 @@ typedef struct MpegEncContext { · 5 unmodified lines | |||
| 174 | * copy of the current picture structure. | 174 | * copy of the current picture structure. |
| 175 | * note, linesize & data, might not match the current picture (for field pictures) | 175 | * note, linesize & data, might not match the current picture (for field pictures) |
| 176 | */ | 176 | */ |
| 177 | MPVPicture cur_pic; | 177 | MPVWorkPicture cur_pic; |
| 178 | 178 | ||
| 179 | MPVPicture *last_pic_ptr; ///< pointer to the previous picture. | ||
| 180 | MPVPicture *next_pic_ptr; ///< pointer to the next picture (for bidir pred) | ||
| 181 | MPVPicture *cur_pic_ptr; ///< pointer to the current picture | ||
| 182 | int skipped_last_frame; | 179 | int skipped_last_frame; |
| 183 | int last_dc[3]; ///< last DC values for MPEG-1 | 180 | int last_dc[3]; ///< last DC values for MPEG-1 |
| 184 | int16_t *dc_val_base; | 181 | int16_t *dc_val_base; |
| @@ -114,12 +114,10 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, · 113 unmodified lines | |||
| 114 | 114 | ||
| 115 | #define UPDATE_PICTURE(pic)\ | 115 | #define UPDATE_PICTURE(pic)\ |
| 116 | do {\ | 116 | do {\ |
| 117 | ff_mpeg_unref_picture(&s->pic);\ | 117 | if (s->picture && s1->picture && s1->pic.ptr && s1->pic.ptr->f->buf[0]) {\ |
| 118 | if (s1->pic.f && s1->pic.f->buf[0]) {\ | 118 | ff_mpv_workpic_from_pic(&s->pic, &s->picture[s1->pic.ptr - s1->picture]);\ |
| 119 | ret = ff_mpeg_ref_picture(&s->pic, &s1->pic);\ | 119 | } else\ |
| 120 | if (ret < 0)\ | 120 | ff_mpv_unref_picture(&s->pic);\ |
| 121 | return ret;\ | ||
| 122 | }\ | ||
| 123 | } while (0) | 121 | } while (0) |
| 124 | 122 | ||
| 125 | UPDATE_PICTURE(cur_pic); | 123 | UPDATE_PICTURE(cur_pic); |
| @@ -129,15 +127,6 @@ do {\ · 3 unmodified lines | |||
| 129 | s->linesize = s1->linesize; | 127 | s->linesize = s1->linesize; |
| 130 | s->uvlinesize = s1->uvlinesize; | 128 | s->uvlinesize = s1->uvlinesize; |
| 131 | 129 | ||
| 132 | #define REBASE_PICTURE(pic, new_ctx, old_ctx) \ | ||
| 133 | ((pic && pic >= old_ctx->picture && \ | ||
| 134 | pic < old_ctx->picture + MAX_PICTURE_COUNT) ? \ | ||
| 135 | &new_ctx->picture[pic - old_ctx->picture] : NULL) | ||
| 136 | |||
| 137 | s->last_pic_ptr = REBASE_PICTURE(s1->last_pic_ptr, s, s1); | ||
| 138 | s->cur_pic_ptr = REBASE_PICTURE(s1->cur_pic_ptr, s, s1); | ||
| 139 | s->next_pic_ptr = REBASE_PICTURE(s1->next_pic_ptr, s, s1); | ||
| 140 | |||
| 141 | // Error/bug resilience | 130 | // Error/bug resilience |
| 142 | s->workaround_bugs = s1->workaround_bugs; | 131 | s->workaround_bugs = s1->workaround_bugs; |
| 143 | s->padding_bug_score = s1->padding_bug_score; | 132 | s->padding_bug_score = s1->padding_bug_score; |
| @@ -193,9 +182,9 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s) · 49 unmodified lines | |||
| 193 | 182 | ||
| 194 | ff_mpv_free_context_frame(s); | 183 | ff_mpv_free_context_frame(s); |
| 195 | 184 | ||
| 196 | s->last_pic_ptr = | 185 | s->last_pic.ptr = |
| 197 | s->next_pic_ptr = | 186 | s->next_pic.ptr = |
| 198 | s->cur_pic_ptr = NULL; | 187 | s->cur_pic.ptr = NULL; |
| 199 | 188 | ||
| 200 | if ((s->width || s->height) && | 189 | if ((s->width || s->height) && |
| 201 | (err = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0) | 190 | (err = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0) |
| @@ -228,7 +217,7 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s) · 26 unmodified lines | |||
| 228 | return err; | 217 | return err; |
| 229 | } | 218 | } |
| 230 | 219 | ||
| 231 | static int alloc_picture(MpegEncContext *s, MPVPicture **picp, int reference) | 220 | static int alloc_picture(MpegEncContext *s, MPVWorkPicture *dst, int reference) |
| 232 | { | 221 | { |
| 233 | AVCodecContext *avctx = s->avctx; | 222 | AVCodecContext *avctx = s->avctx; |
| 234 | int idx = ff_find_unused_picture(s->avctx, s->picture, 0); | 223 | int idx = ff_find_unused_picture(s->avctx, s->picture, 0); |
| @@ -239,6 +228,7 @@ static int alloc_picture(MpegEncContext *s, MPVPicture **picp, int reference) · 4 unmodified lines | |||
| 239 | return idx; | 228 | return idx; |
| 240 | 229 | ||
| 241 | pic = &s->picture[idx]; | 230 | pic = &s->picture[idx]; |
| 231 | dst->ptr = pic; | ||
| 242 | 232 | ||
| 243 | pic->tf.f = pic->f; | 233 | pic->tf.f = pic->f; |
| 244 | pic->reference = reference; | 234 | pic->reference = reference; |
| @@ -271,36 +261,27 @@ static int alloc_picture(MpegEncContext *s, MPVPicture **picp, int reference) · 26 unmodified lines | |||
| 271 | av_assert1(s->mb_height == s->buffer_pools.alloc_mb_height || | 261 | av_assert1(s->mb_height == s->buffer_pools.alloc_mb_height || |
| 272 | FFALIGN(s->mb_height, 2) == s->buffer_pools.alloc_mb_height); | 262 | FFALIGN(s->mb_height, 2) == s->buffer_pools.alloc_mb_height); |
| 273 | av_assert1(s->mb_stride == s->buffer_pools.alloc_mb_stride); | 263 | av_assert1(s->mb_stride == s->buffer_pools.alloc_mb_stride); |
| 274 | ret = ff_mpv_alloc_pic_accessories(s->avctx, pic, &s->me, &s->sc, | 264 | ret = ff_mpv_alloc_pic_accessories(s->avctx, dst, &s->me, &s->sc, |
| 275 | &s->buffer_pools, s->mb_height); | 265 | &s->buffer_pools, s->mb_height); |
| 276 | if (ret < 0) | 266 | if (ret < 0) |
| 277 | goto fail; | 267 | goto fail; |
| 278 | *picp = pic; | ||
| 279 | 268 | ||
| 280 | return 0; | 269 | return 0; |
| 281 | fail: | 270 | fail: |
| 282 | ff_mpeg_unref_picture(pic); | 271 | ff_mpv_unref_picture(dst); |
| 283 | return ret; | 272 | return ret; |
| 284 | } | 273 | } |
| 285 | 274 | ||
| 286 | static int av_cold alloc_dummy_frame(MpegEncContext *s, MPVPicture **picp, MPVPicture *wpic) | 275 | static int av_cold alloc_dummy_frame(MpegEncContext *s, MPVWorkPicture *dst) |
| 287 | { | 276 | { |
| 288 | MPVPicture *pic; | 277 | MPVPicture *pic; |
| 289 | int ret = alloc_picture(s, &pic, 1); | 278 | int ret = alloc_picture(s, dst, 1); |
| 290 | if (ret < 0) | 279 | if (ret < 0) |
| 291 | return ret; | 280 | return ret; |
| 292 | 281 | ||
| 282 | pic = dst->ptr; | ||
| 293 | pic->dummy = 1; | 283 | pic->dummy = 1; |
| 294 | 284 | ||
| 295 | ff_mpeg_unref_picture(wpic); | ||
| 296 | ret = ff_mpeg_ref_picture(wpic, pic); | ||
| 297 | if (ret < 0) { | ||
| 298 | ff_mpeg_unref_picture(pic); | ||
| 299 | return ret; | ||
| 300 | } | ||
| 301 | |||
| 302 | *picp = pic; | ||
| 303 | |||
| 304 | ff_thread_report_progress(&pic->tf, INT_MAX, 0); | 285 | ff_thread_report_progress(&pic->tf, INT_MAX, 0); |
| 305 | ff_thread_report_progress(&pic->tf, INT_MAX, 1); | 286 | ff_thread_report_progress(&pic->tf, INT_MAX, 1); |
| 306 | 287 | ||
| @@ -330,9 +311,9 @@ int ff_mpv_alloc_dummy_frames(MpegEncContext *s) · 23 unmodified lines | |||
| 330 | AVCodecContext *avctx = s->avctx; | 311 | AVCodecContext *avctx = s->avctx; |
| 331 | int ret; | 312 | int ret; |
| 332 | 313 | ||
| 333 | if ((!s->last_pic_ptr || !s->last_pic_ptr->f->buf[0]) && | 314 | if ((!s->last_pic.ptr || !s->last_pic.ptr->f->buf[0]) && |
| 334 | (s->pict_type != AV_PICTURE_TYPE_I)) { | 315 | (s->pict_type != AV_PICTURE_TYPE_I)) { |
| 335 | if (s->pict_type == AV_PICTURE_TYPE_B && s->next_pic_ptr && s->next_pic_ptr->f->buf[0]) | 316 | if (s->pict_type == AV_PICTURE_TYPE_B && s->next_pic.ptr && s->next_pic.ptr->f->buf[0]) |
| 336 | av_log(avctx, AV_LOG_DEBUG, | 317 | av_log(avctx, AV_LOG_DEBUG, |
| 337 | "allocating dummy last picture for B frame\n"); | 318 | "allocating dummy last picture for B frame\n"); |
| 338 | else if (s->codec_id != AV_CODEC_ID_H261 /* H.261 has no keyframes */ && | 319 | else if (s->codec_id != AV_CODEC_ID_H261 /* H.261 has no keyframes */ && |
| @@ -341,25 +322,25 @@ int ff_mpv_alloc_dummy_frames(MpegEncContext *s) · 2 unmodified lines | |||
| 341 | "warning: first frame is no keyframe\n"); | 322 | "warning: first frame is no keyframe\n"); |
| 342 | 323 | ||
| 343 | /* Allocate a dummy frame */ | 324 | /* Allocate a dummy frame */ |
| 344 | ret = alloc_dummy_frame(s, &s->last_pic_ptr, &s->last_pic); | 325 | ret = alloc_dummy_frame(s, &s->last_pic); |
| 345 | if (ret < 0) | 326 | if (ret < 0) |
| 346 | return ret; | 327 | return ret; |
| 347 | 328 | ||
| 348 | if (!avctx->hwaccel) { | 329 | if (!avctx->hwaccel) { |
| 349 | int luma_val = s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263 ? 16 : 0x80; | 330 | int luma_val = s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263 ? 16 : 0x80; |
| 350 | color_frame(s->last_pic_ptr->f, luma_val); | 331 | color_frame(s->last_pic.ptr->f, luma_val); |
| 351 | } | 332 | } |
| 352 | } | 333 | } |
| 353 | if ((!s->next_pic_ptr || !s->next_pic_ptr->f->buf[0]) && | 334 | if ((!s->next_pic.ptr || !s->next_pic.ptr->f->buf[0]) && |
| 354 | s->pict_type == AV_PICTURE_TYPE_B) { | 335 | s->pict_type == AV_PICTURE_TYPE_B) { |
| 355 | /* Allocate a dummy frame */ | 336 | /* Allocate a dummy frame */ |
| 356 | ret = alloc_dummy_frame(s, &s->next_pic_ptr, &s->next_pic); | 337 | ret = alloc_dummy_frame(s, &s->next_pic); |
| 357 | if (ret < 0) | 338 | if (ret < 0) |
| 358 | return ret; | 339 | return ret; |
| 359 | } | 340 | } |
| 360 | 341 | ||
| 361 | av_assert0(s->pict_type == AV_PICTURE_TYPE_I || (s->last_pic_ptr && | 342 | av_assert0(s->pict_type == AV_PICTURE_TYPE_I || (s->last_pic.ptr && |
| 362 | s->last_pic_ptr->f->buf[0])); | 343 | s->last_pic.ptr->f->buf[0])); |
| 363 | 344 | ||
| 364 | return 0; | 345 | return 0; |
| 365 | } | 346 | } |
| @@ -380,68 +361,49 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) · 14 unmodified lines | |||
| 380 | } | 361 | } |
| 381 | 362 | ||
| 382 | /* mark & release old frames */ | 363 | /* mark & release old frames */ |
| 383 | if (s->pict_type != AV_PICTURE_TYPE_B && s->last_pic_ptr && | 364 | if (s->pict_type != AV_PICTURE_TYPE_B && s->last_pic.ptr && |
| 384 | s->last_pic_ptr != s->next_pic_ptr && | 365 | s->last_pic.ptr != s->next_pic.ptr && |
| 385 | s->last_pic_ptr->f->buf[0]) { | 366 | s->last_pic.ptr->f->buf[0]) { |
| 386 | ff_mpeg_unref_picture(s->last_pic_ptr); | 367 | ff_mpeg_unref_picture(s->last_pic.ptr); |
| 387 | } | 368 | } |
| 388 | 369 | ||
| 389 | /* release non reference/forgotten frames */ | 370 | /* release non reference/forgotten frames */ |
| 390 | for (int i = 0; i < MAX_PICTURE_COUNT; i++) { | 371 | for (int i = 0; i < MAX_PICTURE_COUNT; i++) { |
| 391 | if (!s->picture[i].reference || | 372 | if (!s->picture[i].reference || |
| 392 | (&s->picture[i] != s->last_pic_ptr && | 373 | (&s->picture[i] != s->last_pic.ptr && |
| 393 | &s->picture[i] != s->next_pic_ptr)) { | 374 | &s->picture[i] != s->next_pic.ptr)) { |
| 394 | ff_mpeg_unref_picture(&s->picture[i]); | 375 | ff_mpeg_unref_picture(&s->picture[i]); |
| 395 | } | 376 | } |
| 396 | } | 377 | } |
| 397 | 378 | ||
| 398 | ff_mpeg_unref_picture(&s->cur_pic); | 379 | ret = alloc_picture(s, &s->cur_pic, |
| 399 | ff_mpeg_unref_picture(&s->last_pic); | ||
| 400 | ff_mpeg_unref_picture(&s->next_pic); | ||
| 401 | |||
| 402 | ret = alloc_picture(s, &s->cur_pic_ptr, | ||
| 403 | s->pict_type != AV_PICTURE_TYPE_B && !s->droppable); | 380 | s->pict_type != AV_PICTURE_TYPE_B && !s->droppable); |
| 404 | if (ret < 0) | 381 | if (ret < 0) |
| 405 | return ret; | 382 | return ret; |
| 406 | 383 | ||
| 407 | s->cur_pic_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!s->top_field_first; | 384 | s->cur_pic.ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!s->top_field_first; |
| 408 | s->cur_pic_ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * | 385 | s->cur_pic.ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * |
| 409 | (!s->progressive_frame && !s->progressive_sequence); | 386 | (!s->progressive_frame && !s->progressive_sequence); |
| 410 | s->cur_pic_ptr->field_picture = s->picture_structure != PICT_FRAME; | 387 | s->cur_pic.ptr->field_picture = s->picture_structure != PICT_FRAME; |
| 411 | 388 | ||
| 412 | s->cur_pic_ptr->f->pict_type = s->pict_type; | 389 | s->cur_pic.ptr->f->pict_type = s->pict_type; |
| 413 | if (s->pict_type == AV_PICTURE_TYPE_I) | 390 | if (s->pict_type == AV_PICTURE_TYPE_I) |
| 414 | s->cur_pic_ptr->f->flags |= AV_FRAME_FLAG_KEY; | 391 | s->cur_pic.ptr->f->flags |= AV_FRAME_FLAG_KEY; |
| 415 | else | 392 | else |
| 416 | s->cur_pic_ptr->f->flags &= ~AV_FRAME_FLAG_KEY; | 393 | s->cur_pic.ptr->f->flags &= ~AV_FRAME_FLAG_KEY; |
| 417 | |||
| 418 | if ((ret = ff_mpeg_ref_picture(&s->cur_pic, s->cur_pic_ptr)) < 0) | ||
| 419 | return ret; | ||
| 420 | 394 | ||
| 421 | if (s->pict_type != AV_PICTURE_TYPE_B) { | 395 | if (s->pict_type != AV_PICTURE_TYPE_B) { |
| 422 | s->last_pic_ptr = s->next_pic_ptr; | 396 | ff_mpv_workpic_from_pic(&s->last_pic, s->next_pic.ptr); |
| 423 | if (!s->droppable) | 397 | if (!s->droppable) |
| 424 | s->next_pic_ptr = s->cur_pic_ptr; | 398 | ff_mpv_workpic_from_pic(&s->next_pic, s->cur_pic.ptr); |
| 425 | } | 399 | } |
| 426 | ff_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n", | 400 | ff_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n", |
| 427 | s->last_pic_ptr, s->next_pic_ptr, s->cur_pic_ptr, | 401 | (void*)s->last_pic.ptr, (void*)s->next_pic.ptr, (void*)s->cur_pic.ptr, |
| 428 | s->last_pic_ptr ? s->last_pic_ptr->f->data[0] : NULL, | 402 | s->last_pic.ptr ? s->last_pic.ptr->f->data[0] : NULL, |
| 429 | s->next_pic_ptr ? s->next_pic_ptr->f->data[0] : NULL, | 403 | s->next_pic.ptr ? s->next_pic.ptr->f->data[0] : NULL, |
| 430 | s->cur_pic_ptr ? s->cur_pic_ptr->f->data[0] : NULL, | 404 | s->cur_pic.ptr ? s->cur_pic.ptr->f->data[0] : NULL, |
| 431 | s->pict_type, s->droppable); | 405 | s->pict_type, s->droppable); |
| 432 | 406 | ||
| 433 | if (s->last_pic_ptr) { | ||
| 434 | if (s->last_pic_ptr->f->buf[0] && | ||
| 435 | (ret = ff_mpeg_ref_picture(&s->last_pic, | ||
| 436 | s->last_pic_ptr)) < 0) | ||
| 437 | return ret; | ||
| 438 | } | ||
| 439 | if (s->next_pic_ptr) { | ||
| 440 | if (s->next_pic_ptr->f->buf[0] && | ||
| 441 | (ret = ff_mpeg_ref_picture(&s->next_pic, s->next_pic_ptr)) < 0) | ||
| 442 | return ret; | ||
| 443 | } | ||
| 444 | |||
| 445 | ret = ff_mpv_alloc_dummy_frames(s); | 407 | ret = ff_mpv_alloc_dummy_frames(s); |
| 446 | if (ret < 0) | 408 | if (ret < 0) |
| 447 | return ret; | 409 | return ret; |
| @@ -461,7 +423,7 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) · 13 unmodified lines | |||
| 461 | } | 423 | } |
| 462 | 424 | ||
| 463 | if (s->avctx->debug & FF_DEBUG_NOMC) | 425 | if (s->avctx->debug & FF_DEBUG_NOMC) |
| 464 | color_frame(s->cur_pic_ptr->f, 0x80); | 426 | color_frame(s->cur_pic.ptr->f, 0x80); |
| 465 | 427 | ||
| 466 | return 0; | 428 | return 0; |
| 467 | } | 429 | } |
| @@ -472,7 +434,7 @@ void ff_mpv_frame_end(MpegEncContext *s) · 4 unmodified lines | |||
| 472 | emms_c(); | 434 | emms_c(); |
| 473 | 435 | ||
| 474 | if (s->cur_pic.reference) | 436 | if (s->cur_pic.reference) |
| 475 | ff_thread_report_progress(&s->cur_pic_ptr->tf, INT_MAX, 0); | 437 | ff_thread_report_progress(&s->cur_pic.ptr->tf, INT_MAX, 0); |
| 476 | } | 438 | } |
| 477 | 439 | ||
| 478 | void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict) | 440 | void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict) |
| @@ -515,8 +477,8 @@ int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f, · 36 unmodified lines | |||
| 515 | 477 | ||
| 516 | void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h) | 478 | void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h) |
| 517 | { | 479 | { |
| 518 | ff_draw_horiz_band(s->avctx, s->cur_pic_ptr->f, | 480 | ff_draw_horiz_band(s->avctx, s->cur_pic.ptr->f, |
| 519 | s->last_pic_ptr ? s->last_pic_ptr->f : NULL, | 481 | s->last_pic.ptr ? s->last_pic.ptr->f : NULL, |
| 520 | y, h, s->picture_structure, | 482 | y, h, s->picture_structure, |
| 521 | s->first_field, s->low_delay); | 483 | s->first_field, s->low_delay); |
| 522 | } | 484 | } |
| @@ -530,11 +492,10 @@ void ff_mpeg_flush(AVCodecContext *avctx) · 7 unmodified lines | |||
| 530 | 492 | ||
| 531 | for (int i = 0; i < MAX_PICTURE_COUNT; i++) | 493 | for (int i = 0; i < MAX_PICTURE_COUNT; i++) |
| 532 | ff_mpeg_unref_picture(&s->picture[i]); | 494 | ff_mpeg_unref_picture(&s->picture[i]); |
| 533 | s->cur_pic_ptr = s->last_pic_ptr = s->next_pic_ptr = NULL; | ||
| 534 | 495 | ||
| 535 | ff_mpeg_unref_picture(&s->cur_pic); | 496 | ff_mpv_unref_picture(&s->cur_pic); |
| 536 | ff_mpeg_unref_picture(&s->last_pic); | 497 | ff_mpv_unref_picture(&s->last_pic); |
| 537 | ff_mpeg_unref_picture(&s->next_pic); | 498 | ff_mpv_unref_picture(&s->next_pic); |
| 538 | 499 | ||
| 539 | s->mb_x = s->mb_y = 0; | 500 | s->mb_x = s->mb_y = 0; |
| 540 | 501 | ||
| @@ -545,7 +506,7 @@ void ff_mpeg_flush(AVCodecContext *avctx) · 4 unmodified lines | |||
| 545 | void ff_mpv_report_decode_progress(MpegEncContext *s) | 506 | void ff_mpv_report_decode_progress(MpegEncContext *s) |
| 546 | { | 507 | { |
| 547 | if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred) | 508 | if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred) |
| 548 | ff_thread_report_progress(&s->cur_pic_ptr->tf, s->mb_y, 0); | 509 | ff_thread_report_progress(&s->cur_pic.ptr->tf, s->mb_y, 0); |
| 549 | } | 510 | } |
| 550 | 511 | ||
| 551 | 512 | ||
| @@ -864,7 +825,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s, · 312 unmodified lines | |||
| 864 | } else { | 825 | } else { |
| 865 | if (s->picture_structure != s->field_select[dir][0] + 1 && | 826 | if (s->picture_structure != s->field_select[dir][0] + 1 && |
| 866 | s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) { | 827 | s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) { |
| 867 | ref_picture = s->cur_pic_ptr->f->data; | 828 | ref_picture = s->cur_pic.ptr->f->data; |
| 868 | } | 829 | } |
| 869 | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | 830 | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, |
| 870 | 0, 0, s->field_select[dir][0], | 831 | 0, 0, s->field_select[dir][0], |
| @@ -881,7 +842,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s, · 10 unmodified lines | |||
| 881 | s->pict_type == AV_PICTURE_TYPE_B || s->first_field) { | 842 | s->pict_type == AV_PICTURE_TYPE_B || s->first_field) { |
| 882 | ref2picture = ref_picture; | 843 | ref2picture = ref_picture; |
| 883 | } else { | 844 | } else { |
| 884 | ref2picture = s->cur_pic_ptr->f->data; | 845 | ref2picture = s->cur_pic.ptr->f->data; |
| 885 | } | 846 | } |
| 886 | 847 | ||
| 887 | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | 848 | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, |
| @@ -922,7 +883,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s, · 34 unmodified lines | |||
| 922 | // opposite parity is always in the same | 883 | // opposite parity is always in the same |
| 923 | // frame if this is second field | 884 | // frame if this is second field |
| 924 | if (!s->first_field) { | 885 | if (!s->first_field) { |
| 925 | ref_picture = s->cur_pic_ptr->f->data; | 886 | ref_picture = s->cur_pic.ptr->f->data; |
| 926 | } | 887 | } |
| 927 | } | 888 | } |
| 928 | } | 889 | } |
| @@ -1356,7 +1356,7 @@ static int estimate_best_b_count(MpegEncContext *s) · 1355 unmodified lines | |||
| 1356 | 1356 | ||
| 1357 | for (i = 0; i < s->max_b_frames + 2; i++) { | 1357 | for (i = 0; i < s->max_b_frames + 2; i++) { |
| 1358 | const MPVPicture *pre_input_ptr = i ? s->input_picture[i - 1] : | 1358 | const MPVPicture *pre_input_ptr = i ? s->input_picture[i - 1] : |
| 1359 | s->next_pic_ptr; | 1359 | s->next_pic.ptr; |
| 1360 | 1360 | ||
| 1361 | if (pre_input_ptr) { | 1361 | if (pre_input_ptr) { |
| 1362 | const uint8_t *data[4]; | 1362 | const uint8_t *data[4]; |
| @@ -1484,8 +1484,8 @@ static int select_input_picture(MpegEncContext *s) · 121 unmodified lines | |||
| 1484 | if (!s->reordered_input_picture[0] && s->input_picture[0]) { | 1484 | if (!s->reordered_input_picture[0] && s->input_picture[0]) { |
| 1485 | if (s->frame_skip_threshold || s->frame_skip_factor) { | 1485 | if (s->frame_skip_threshold || s->frame_skip_factor) { |
| 1486 | if (s->picture_in_gop_number < s->gop_size && | 1486 | if (s->picture_in_gop_number < s->gop_size && |
| 1487 | s->next_pic_ptr && | 1487 | s->next_pic.ptr && |
| 1488 | skip_check(s, s->input_picture[0], s->next_pic_ptr)) { | 1488 | skip_check(s, s->input_picture[0], s->next_pic.ptr)) { |
| 1489 | // FIXME check that the gop check above is +-1 correct | 1489 | // FIXME check that the gop check above is +-1 correct |
| 1490 | ff_mpeg_unref_picture(s->input_picture[0]); | 1490 | ff_mpeg_unref_picture(s->input_picture[0]); |
| 1491 | 1491 | ||
| @@ -1496,7 +1496,7 @@ static int select_input_picture(MpegEncContext *s) · 4 unmodified lines | |||
| 1496 | } | 1496 | } |
| 1497 | 1497 | ||
| 1498 | if (/*s->picture_in_gop_number >= s->gop_size ||*/ | 1498 | if (/*s->picture_in_gop_number >= s->gop_size ||*/ |
| 1499 | !s->next_pic_ptr || s->intra_only) { | 1499 | !s->next_pic.ptr || s->intra_only) { |
| 1500 | s->reordered_input_picture[0] = s->input_picture[0]; | 1500 | s->reordered_input_picture[0] = s->input_picture[0]; |
| 1501 | s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I; | 1501 | s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I; |
| 1502 | s->reordered_input_picture[0]->coded_picture_number = | 1502 | s->reordered_input_picture[0]->coded_picture_number = |
| @@ -1624,17 +1624,17 @@ no_output_pic: · 121 unmodified lines | |||
| 1624 | s->new_pic->data[i] += INPLACE_OFFSET; | 1624 | s->new_pic->data[i] += INPLACE_OFFSET; |
| 1625 | } | 1625 | } |
| 1626 | } | 1626 | } |
| 1627 | s->cur_pic_ptr = s->reordered_input_picture[0]; | 1627 | s->cur_pic.ptr = s->reordered_input_picture[0]; |
| 1628 | av_assert1(s->mb_width == s->buffer_pools.alloc_mb_width); | 1628 | av_assert1(s->mb_width == s->buffer_pools.alloc_mb_width); |
| 1629 | av_assert1(s->mb_height == s->buffer_pools.alloc_mb_height); | 1629 | av_assert1(s->mb_height == s->buffer_pools.alloc_mb_height); |
| 1630 | av_assert1(s->mb_stride == s->buffer_pools.alloc_mb_stride); | 1630 | av_assert1(s->mb_stride == s->buffer_pools.alloc_mb_stride); |
| 1631 | ret = ff_mpv_alloc_pic_accessories(s->avctx, s->cur_pic_ptr, &s->me, | 1631 | ret = ff_mpv_alloc_pic_accessories(s->avctx, &s->cur_pic, &s->me, |
| 1632 | &s->sc, &s->buffer_pools, s->mb_height); | 1632 | &s->sc, &s->buffer_pools, s->mb_height); |
| 1633 | if (ret < 0) { | 1633 | if (ret < 0) { |
| 1634 | ff_mpeg_unref_picture(s->cur_pic_ptr); | 1634 | ff_mpv_unref_picture(&s->cur_pic); |
| 1635 | return ret; | 1635 | return ret; |
| 1636 | } | 1636 | } |
| 1637 | s->picture_number = s->cur_pic_ptr->display_picture_number; | 1637 | s->picture_number = s->cur_pic.ptr->display_picture_number; |
| 1638 | 1638 | ||
| 1639 | } | 1639 | } |
| 1640 | return 0; | 1640 | return 0; |
| @@ -1674,7 +1674,7 @@ static void frame_end(MpegEncContext *s) · 33 unmodified lines | |||
| 1674 | emms_c(); | 1674 | emms_c(); |
| 1675 | 1675 | ||
| 1676 | s->last_pict_type = s->pict_type; | 1676 | s->last_pict_type = s->pict_type; |
| 1677 | s->last_lambda_for [s->pict_type] = s->cur_pic_ptr->f->quality; | 1677 | s->last_lambda_for [s->pict_type] = s->cur_pic.ptr->f->quality; |
| 1678 | if (s->pict_type!= AV_PICTURE_TYPE_B) | 1678 | if (s->pict_type!= AV_PICTURE_TYPE_B) |
| 1679 | s->last_non_b_pict_type = s->pict_type; | 1679 | s->last_non_b_pict_type = s->pict_type; |
| 1680 | } | 1680 | } |
| @@ -1700,47 +1700,26 @@ static void update_noise_reduction(MpegEncContext *s) · 19 unmodified lines | |||
| 1700 | } | 1700 | } |
| 1701 | } | 1701 | } |
| 1702 | 1702 | ||
| 1703 | static int frame_start(MpegEncContext *s) | 1703 | static void frame_start(MpegEncContext *s) |
| 1704 | { | 1704 | { |
| 1705 | int ret; | ||
| 1706 | |||
| 1707 | /* mark & release old frames */ | 1705 | /* mark & release old frames */ |
| 1708 | if (s->pict_type != AV_PICTURE_TYPE_B && s->last_pic_ptr && | 1706 | if (s->pict_type != AV_PICTURE_TYPE_B && s->last_pic.ptr && |
| 1709 | s->last_pic_ptr != s->next_pic_ptr && | 1707 | s->last_pic.ptr != s->next_pic.ptr && |
| 1710 | s->last_pic_ptr->f->buf[0]) { | 1708 | s->last_pic.ptr->f->buf[0]) { |
| 1711 | ff_mpeg_unref_picture(s->last_pic_ptr); | 1709 | ff_mpv_unref_picture(&s->last_pic); |
| 1712 | } | 1710 | } |
| 1713 | 1711 | ||
| 1714 | s->cur_pic_ptr->f->pict_type = s->pict_type; | 1712 | s->cur_pic.ptr->f->pict_type = s->pict_type; |
| 1715 | |||
| 1716 | ff_mpeg_unref_picture(&s->cur_pic); | ||
| 1717 | if ((ret = ff_mpeg_ref_picture(&s->cur_pic, s->cur_pic_ptr)) < 0) | ||
| 1718 | return ret; | ||
| 1719 | 1713 | ||
| 1720 | if (s->pict_type != AV_PICTURE_TYPE_B) { | 1714 | if (s->pict_type != AV_PICTURE_TYPE_B) { |
| 1721 | s->last_pic_ptr = s->next_pic_ptr; | 1715 | ff_mpv_replace_picture(&s->last_pic, &s->next_pic); |
| 1722 | s->next_pic_ptr = s->cur_pic_ptr; | 1716 | ff_mpv_replace_picture(&s->next_pic, &s->cur_pic); |
| 1723 | } | ||
| 1724 | |||
| 1725 | if (s->last_pic_ptr) { | ||
| 1726 | ff_mpeg_unref_picture(&s->last_pic); | ||
| 1727 | if (s->last_pic_ptr->f->buf[0] && | ||
| 1728 | (ret = ff_mpeg_ref_picture(&s->last_pic, s->last_pic_ptr)) < 0) | ||
| 1729 | return ret; | ||
| 1730 | } | ||
| 1731 | if (s->next_pic_ptr) { | ||
| 1732 | ff_mpeg_unref_picture(&s->next_pic); | ||
| 1733 | if (s->next_pic_ptr->f->buf[0] && | ||
| 1734 | (ret = ff_mpeg_ref_picture(&s->next_pic, s->next_pic_ptr)) < 0) | ||
| 1735 | return ret; | ||
| 1736 | } | 1717 | } |
| 1737 | 1718 | ||
| 1738 | if (s->dct_error_sum) { | 1719 | if (s->dct_error_sum) { |
| 1739 | av_assert2(s->noise_reduction && s->encoding); | 1720 | av_assert2(s->noise_reduction && s->encoding); |
| 1740 | update_noise_reduction(s); | 1721 | update_noise_reduction(s); |
| 1741 | } | 1722 | } |
| 1742 | |||
| 1743 | return 0; | ||
| 1744 | } | 1723 | } |
| 1745 | 1724 | ||
| 1746 | int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, | 1725 | int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, |
| @@ -1793,9 +1772,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, · 46 unmodified lines | |||
| 1793 | 1772 | ||
| 1794 | s->pict_type = s->new_pic->pict_type; | 1773 | s->pict_type = s->new_pic->pict_type; |
| 1795 | //emms_c(); | 1774 | //emms_c(); |
| 1796 | ret = frame_start(s); | 1775 | frame_start(s); |
| 1797 | if (ret < 0) | ||
| 1798 | return ret; | ||
| 1799 | vbv_retry: | 1776 | vbv_retry: |
| 1800 | ret = encode_picture(s); | 1777 | ret = encode_picture(s); |
| 1801 | if (growing_buffer) { | 1778 | if (growing_buffer) { |
| @@ -1858,7 +1835,7 @@ vbv_retry: · 56 unmodified lines | |||
| 1858 | 1835 | ||
| 1859 | for (int i = 0; i < MPV_MAX_PLANES; i++) | 1836 | for (int i = 0; i < MPV_MAX_PLANES; i++) |
| 1860 | avctx->error[i] += s->encoding_error[i]; | 1837 | avctx->error[i] += s->encoding_error[i]; |
| 1861 | ff_side_data_set_encoder_stats(pkt, s->cur_pic.f->quality, | 1838 | ff_side_data_set_encoder_stats(pkt, s->cur_pic.ptr->f->quality, |
| 1862 | s->encoding_error, | 1839 | s->encoding_error, |
| 1863 | (avctx->flags&AV_CODEC_FLAG_PSNR) ? MPV_MAX_PLANES : 0, | 1840 | (avctx->flags&AV_CODEC_FLAG_PSNR) ? MPV_MAX_PLANES : 0, |
| 1864 | s->pict_type); | 1841 | s->pict_type); |
| @@ -1952,10 +1929,10 @@ vbv_retry: · 87 unmodified lines | |||
| 1952 | } | 1929 | } |
| 1953 | s->total_bits += s->frame_bits; | 1930 | s->total_bits += s->frame_bits; |
| 1954 | 1931 | ||
| 1955 | pkt->pts = s->cur_pic.f->pts; | 1932 | pkt->pts = s->cur_pic.ptr->f->pts; |
| 1956 | pkt->duration = s->cur_pic.f->duration; | 1933 | pkt->duration = s->cur_pic.ptr->f->duration; |
| 1957 | if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) { | 1934 | if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) { |
| 1958 | if (!s->cur_pic.coded_picture_number) | 1935 | if (!s->cur_pic.ptr->coded_picture_number) |
| 1959 | pkt->dts = pkt->pts - s->dts_delta; | 1936 | pkt->dts = pkt->pts - s->dts_delta; |
| 1960 | else | 1937 | else |
| 1961 | pkt->dts = s->reordered_pts; | 1938 | pkt->dts = s->reordered_pts; |
| @@ -1965,12 +1942,12 @@ vbv_retry: · 3 unmodified lines | |||
| 1965 | 1942 | ||
| 1966 | // the no-delay case is handled in generic code | 1943 | // the no-delay case is handled in generic code |
| 1967 | if (avctx->codec->capabilities & AV_CODEC_CAP_DELAY) { | 1944 | if (avctx->codec->capabilities & AV_CODEC_CAP_DELAY) { |
| 1968 | ret = ff_encode_reordered_opaque(avctx, pkt, s->cur_pic.f); | 1945 | ret = ff_encode_reordered_opaque(avctx, pkt, s->cur_pic.ptr->f); |
| 1969 | if (ret < 0) | 1946 | if (ret < 0) |
| 1970 | return ret; | 1947 | return ret; |
| 1971 | } | 1948 | } |
| 1972 | 1949 | ||
| 1973 | if (s->cur_pic.f->flags & AV_FRAME_FLAG_KEY) | 1950 | if (s->cur_pic.ptr->f->flags & AV_FRAME_FLAG_KEY) |
| 1974 | pkt->flags |= AV_PKT_FLAG_KEY; | 1951 | pkt->flags |= AV_PKT_FLAG_KEY; |
| 1975 | if (s->mb_info) | 1952 | if (s->mb_info) |
| 1976 | av_packet_shrink_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size); | 1953 | av_packet_shrink_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size); |
| @@ -3512,14 +3489,12 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src) · 1535 unmodified lines | |||
| 3512 | 3489 | ||
| 3513 | static int estimate_qp(MpegEncContext *s, int dry_run){ | 3490 | static int estimate_qp(MpegEncContext *s, int dry_run){ |
| 3514 | if (s->next_lambda){ | 3491 | if (s->next_lambda){ |
| 3515 | s->cur_pic_ptr->f->quality = | 3492 | s->cur_pic.ptr->f->quality = s->next_lambda; |
| 3516 | s->cur_pic.f->quality = s->next_lambda; | ||
| 3517 | if(!dry_run) s->next_lambda= 0; | 3493 | if(!dry_run) s->next_lambda= 0; |
| 3518 | } else if (!s->fixed_qscale) { | 3494 | } else if (!s->fixed_qscale) { |
| 3519 | int quality = ff_rate_estimate_qscale(s, dry_run); | 3495 | int quality = ff_rate_estimate_qscale(s, dry_run); |
| 3520 | s->cur_pic_ptr->f->quality = | 3496 | s->cur_pic.ptr->f->quality = quality; |
| 3521 | s->cur_pic.f->quality = quality; | 3497 | if (s->cur_pic.ptr->f->quality < 0) |
| 3522 | if (s->cur_pic.f->quality < 0) | ||
| 3523 | return -1; | 3498 | return -1; |
| 3524 | } | 3499 | } |
| 3525 | 3500 | ||
| @@ -3542,15 +3517,15 @@ static int estimate_qp(MpegEncContext *s, int dry_run){ · 16 unmodified lines | |||
| 3542 | s->lambda= s->lambda_table[0]; | 3517 | s->lambda= s->lambda_table[0]; |
| 3543 | //FIXME broken | 3518 | //FIXME broken |
| 3544 | }else | 3519 | }else |
| 3545 | s->lambda = s->cur_pic.f->quality; | 3520 | s->lambda = s->cur_pic.ptr->f->quality; |
| 3546 | update_qscale(s); | 3521 | update_qscale(s); |
| 3547 | return 0; | 3522 | return 0; |
| 3548 | } | 3523 | } |
| 3549 | 3524 | ||
| 3550 | /* must be called before writing the header */ | 3525 | /* must be called before writing the header */ |
| 3551 | static void set_frame_distances(MpegEncContext * s){ | 3526 | static void set_frame_distances(MpegEncContext * s){ |
| 3552 | av_assert1(s->cur_pic_ptr->f->pts != AV_NOPTS_VALUE); | 3527 | av_assert1(s->cur_pic.ptr->f->pts != AV_NOPTS_VALUE); |
| 3553 | s->time = s->cur_pic_ptr->f->pts * s->avctx->time_base.num; | 3528 | s->time = s->cur_pic.ptr->f->pts * s->avctx->time_base.num; |
| 3554 | 3529 | ||
| 3555 | if(s->pict_type==AV_PICTURE_TYPE_B){ | 3530 | if(s->pict_type==AV_PICTURE_TYPE_B){ |
| 3556 | s->pb_time= s->pp_time - (s->last_non_b_time - s->time); | 3531 | s->pb_time= s->pp_time - (s->last_non_b_time - s->time); |
| @@ -3581,7 +3556,7 @@ static int encode_picture(MpegEncContext *s) · 24 unmodified lines | |||
| 3581 | 3556 | ||
| 3582 | s->me.scene_change_score=0; | 3557 | s->me.scene_change_score=0; |
| 3583 | 3558 | ||
| 3584 | // s->lambda= s->cur_pic_ptr->quality; //FIXME qscale / ... stuff for ME rate distortion | 3559 | // s->lambda= s->cur_pic.ptr->quality; //FIXME qscale / ... stuff for ME rate distortion |
| 3585 | 3560 | ||
| 3586 | if(s->pict_type==AV_PICTURE_TYPE_I){ | 3561 | if(s->pict_type==AV_PICTURE_TYPE_I){ |
| 3587 | if(s->msmpeg4_version >= 3) s->no_rounding=1; | 3562 | if(s->msmpeg4_version >= 3) s->no_rounding=1; |
| @@ -3769,18 +3744,14 @@ static int encode_picture(MpegEncContext *s) · 181 unmodified lines | |||
| 3769 | } | 3744 | } |
| 3770 | } | 3745 | } |
| 3771 | 3746 | ||
| 3772 | //FIXME var duplication | ||
| 3773 | if (s->pict_type == AV_PICTURE_TYPE_I) { | 3747 | if (s->pict_type == AV_PICTURE_TYPE_I) { |
| 3774 | s->cur_pic_ptr->f->flags |= AV_FRAME_FLAG_KEY; //FIXME pic_ptr | 3748 | s->cur_pic.ptr->f->flags |= AV_FRAME_FLAG_KEY; |
| 3775 | s->cur_pic.f->flags |= AV_FRAME_FLAG_KEY; | ||
| 3776 | } else { | 3749 | } else { |
| 3777 | s->cur_pic_ptr->f->flags &= ~AV_FRAME_FLAG_KEY; //FIXME pic_ptr | 3750 | s->cur_pic.ptr->f->flags &= ~AV_FRAME_FLAG_KEY; |
| 3778 | s->cur_pic.f->flags &= ~AV_FRAME_FLAG_KEY; | ||
| 3779 | } | 3751 | } |
| 3780 | s->cur_pic_ptr->f->pict_type = | 3752 | s->cur_pic.ptr->f->pict_type = s->pict_type; |
| 3781 | s->cur_pic.f->pict_type = s->pict_type; | ||
| 3782 | 3753 | ||
| 3783 | if (s->cur_pic.f->flags & AV_FRAME_FLAG_KEY) | 3754 | if (s->cur_pic.ptr->f->flags & AV_FRAME_FLAG_KEY) |
| 3784 | s->picture_in_gop_number=0; | 3755 | s->picture_in_gop_number=0; |
| 3785 | 3756 | ||
| 3786 | s->mb_x = s->mb_y = 0; | 3757 | s->mb_x = s->mb_y = 0; |
| @@ -514,7 +514,7 @@ static inline void apply_obmc(MpegEncContext *s, · 513 unmodified lines | |||
| 514 | const op_pixels_func (*pix_op)[4]) | 514 | const op_pixels_func (*pix_op)[4]) |
| 515 | { | 515 | { |
| 516 | LOCAL_ALIGNED_8(int16_t, mv_cache, [4], [4][2]); | 516 | LOCAL_ALIGNED_8(int16_t, mv_cache, [4], [4][2]); |
| 517 | const MPVPicture *cur_frame = &s->cur_pic; | 517 | const MPVWorkPicture *cur_frame = &s->cur_pic; |
| 518 | int mb_x = s->mb_x; | 518 | int mb_x = s->mb_x; |
| 519 | int mb_y = s->mb_y; | 519 | int mb_y = s->mb_y; |
| 520 | const int xy = mb_x + mb_y * s->mb_stride; | 520 | const int xy = mb_x + mb_y * s->mb_stride; |
| @@ -749,7 +749,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s, · 228 unmodified lines | |||
| 749 | av_assert2(s->out_format == FMT_MPEG1); | 749 | av_assert2(s->out_format == FMT_MPEG1); |
| 750 | if (s->picture_structure != s->field_select[dir][0] + 1 && | 750 | if (s->picture_structure != s->field_select[dir][0] + 1 && |
| 751 | s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) { | 751 | s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) { |
| 752 | ref_picture = s->cur_pic_ptr->f->data; | 752 | ref_picture = s->cur_pic.ptr->f->data; |
| 753 | } | 753 | } |
| 754 | 754 | ||
| 755 | mpeg_motion(s, dest_y, dest_cb, dest_cr, | 755 | mpeg_motion(s, dest_y, dest_cb, dest_cr, |
| @@ -767,7 +767,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s, · 11 unmodified lines | |||
| 767 | s->pict_type == AV_PICTURE_TYPE_B || s->first_field) { | 767 | s->pict_type == AV_PICTURE_TYPE_B || s->first_field) { |
| 768 | ref2picture = ref_picture; | 768 | ref2picture = ref_picture; |
| 769 | } else { | 769 | } else { |
| 770 | ref2picture = s->cur_pic_ptr->f->data; | 770 | ref2picture = s->cur_pic.ptr->f->data; |
| 771 | } | 771 | } |
| 772 | 772 | ||
| 773 | mpeg_motion(s, dest_y, dest_cb, dest_cr, | 773 | mpeg_motion(s, dest_y, dest_cb, dest_cr, |
| @@ -807,7 +807,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s, · 33 unmodified lines | |||
| 807 | /* opposite parity is always in the same frame if this is | 807 | /* opposite parity is always in the same frame if this is |
| 808 | * second field */ | 808 | * second field */ |
| 809 | if (!s->first_field) | 809 | if (!s->first_field) |
| 810 | ref_picture = s->cur_pic_ptr->f->data; | 810 | ref_picture = s->cur_pic.ptr->f->data; |
| 811 | } | 811 | } |
| 812 | } | 812 | } |
| 813 | break; | 813 | break; |
| @@ -124,11 +124,11 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], · 123 unmodified lines | |||
| 124 | if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12 && | 124 | if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12 && |
| 125 | s->avctx->active_thread_type & FF_THREAD_FRAME) { | 125 | s->avctx->active_thread_type & FF_THREAD_FRAME) { |
| 126 | if (s->mv_dir & MV_DIR_FORWARD) { | 126 | if (s->mv_dir & MV_DIR_FORWARD) { |
| 127 | ff_thread_await_progress(&s->last_pic_ptr->tf, | 127 | ff_thread_await_progress(&s->last_pic.ptr->tf, |
| 128 | lowest_referenced_row(s, 0), 0); | 128 | lowest_referenced_row(s, 0), 0); |
| 129 | } | 129 | } |
| 130 | if (s->mv_dir & MV_DIR_BACKWARD) { | 130 | if (s->mv_dir & MV_DIR_BACKWARD) { |
| 131 | ff_thread_await_progress(&s->next_pic_ptr->tf, | 131 | ff_thread_await_progress(&s->next_pic.ptr->tf, |
| 132 | lowest_referenced_row(s, 1), 0); | 132 | lowest_referenced_row(s, 1), 0); |
| 133 | } | 133 | } |
| 134 | } | 134 | } |
| @@ -382,7 +382,7 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, · 381 unmodified lines | |||
| 382 | MSS12Context *c = &ctx->c; | 382 | MSS12Context *c = &ctx->c; |
| 383 | VC1Context *v = avctx->priv_data; | 383 | VC1Context *v = avctx->priv_data; |
| 384 | MpegEncContext *s = &v->s; | 384 | MpegEncContext *s = &v->s; |
| 385 | MPVPicture *f; | 385 | MPVWorkPicture *f; |
| 386 | int ret; | 386 | int ret; |
| 387 | 387 | ||
| 388 | ff_mpeg_flush(avctx); | 388 | ff_mpeg_flush(avctx); |
| @@ -39,7 +39,7 @@ static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t *buffer · 38 unmodified lines | |||
| 39 | CUVIDMPEG2PICPARAMS *ppc = &pp->CodecSpecific.mpeg2; | 39 | CUVIDMPEG2PICPARAMS *ppc = &pp->CodecSpecific.mpeg2; |
| 40 | FrameDecodeData *fdd; | 40 | FrameDecodeData *fdd; |
| 41 | NVDECFrame *cf; | 41 | NVDECFrame *cf; |
| 42 | AVFrame *cur_frame = s->cur_pic.f; | 42 | AVFrame *cur_frame = s->cur_pic.ptr->f; |
| 43 | 43 | ||
| 44 | int ret, i; | 44 | int ret, i; |
| 45 | 45 | ||
| @@ -64,8 +64,8 @@ static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t *buffer · 18 unmodified lines | |||
| 64 | s->pict_type == AV_PICTURE_TYPE_P, | 64 | s->pict_type == AV_PICTURE_TYPE_P, |
| 65 | 65 | ||
| 66 | .CodecSpecific.mpeg2 = { | 66 | .CodecSpecific.mpeg2 = { |
| 67 | .ForwardRefIdx = ff_nvdec_get_ref_idx(s->last_pic.f), | 67 | .ForwardRefIdx = ff_nvdec_get_ref_idx(s->last_pic.ptr ? s->last_pic.ptr->f : NULL), |
| 68 | .BackwardRefIdx = ff_nvdec_get_ref_idx(s->next_pic.f), | 68 | .BackwardRefIdx = ff_nvdec_get_ref_idx(s->next_pic.ptr ? s->next_pic.ptr->f : NULL), |
| 69 | 69 | ||
| 70 | .picture_coding_type = s->pict_type, | 70 | .picture_coding_type = s->pict_type, |
| 71 | .full_pel_forward_vector = s->full_pel[0], | 71 | .full_pel_forward_vector = s->full_pel[0], |
| @@ -38,7 +38,7 @@ static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, · 37 unmodified lines | |||
| 38 | CUVIDMPEG4PICPARAMS *ppc = &pp->CodecSpecific.mpeg4; | 38 | CUVIDMPEG4PICPARAMS *ppc = &pp->CodecSpecific.mpeg4; |
| 39 | FrameDecodeData *fdd; | 39 | FrameDecodeData *fdd; |
| 40 | NVDECFrame *cf; | 40 | NVDECFrame *cf; |
| 41 | AVFrame *cur_frame = s->cur_pic.f; | 41 | AVFrame *cur_frame = s->cur_pic.ptr->f; |
| 42 | 42 | ||
| 43 | int ret, i; | 43 | int ret, i; |
| 44 | 44 | ||
| @@ -60,8 +60,8 @@ static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, · 15 unmodified lines | |||
| 60 | s->pict_type == AV_PICTURE_TYPE_S, | 60 | s->pict_type == AV_PICTURE_TYPE_S, |
| 61 | 61 | ||
| 62 | .CodecSpecific.mpeg4 = { | 62 | .CodecSpecific.mpeg4 = { |
| 63 | .ForwardRefIdx = ff_nvdec_get_ref_idx(s->last_pic.f), | 63 | .ForwardRefIdx = ff_nvdec_get_ref_idx(s->last_pic.ptr ? s->last_pic.ptr->f : NULL), |
| 64 | .BackwardRefIdx = ff_nvdec_get_ref_idx(s->next_pic.f), | 64 | .BackwardRefIdx = ff_nvdec_get_ref_idx(s->next_pic.ptr ? s->next_pic.ptr->f : NULL), |
| 65 | 65 | ||
| 66 | .video_object_layer_width = s->width, | 66 | .video_object_layer_width = s->width, |
| 67 | .video_object_layer_height = s->height, | 67 | .video_object_layer_height = s->height, |
| @@ -38,7 +38,7 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u · 37 unmodified lines | |||
| 38 | CUVIDPICPARAMS *pp = &ctx->pic_params; | 38 | CUVIDPICPARAMS *pp = &ctx->pic_params; |
| 39 | FrameDecodeData *fdd; | 39 | FrameDecodeData *fdd; |
| 40 | NVDECFrame *cf; | 40 | NVDECFrame *cf; |
| 41 | AVFrame *cur_frame = s->cur_pic.f; | 41 | AVFrame *cur_frame = s->cur_pic.ptr->f; |
| 42 | 42 | ||
| 43 | int ret; | 43 | int ret; |
| 44 | 44 | ||
| @@ -63,8 +63,8 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u · 18 unmodified lines | |||
| 63 | s->pict_type == AV_PICTURE_TYPE_P, | 63 | s->pict_type == AV_PICTURE_TYPE_P, |
| 64 | 64 | ||
| 65 | .CodecSpecific.vc1 = { | 65 | .CodecSpecific.vc1 = { |
| 66 | .ForwardRefIdx = ff_nvdec_get_ref_idx(s->last_pic.f), | 66 | .ForwardRefIdx = ff_nvdec_get_ref_idx(s->last_pic.ptr ? s->last_pic.ptr->f : NULL), |
| 67 | .BackwardRefIdx = ff_nvdec_get_ref_idx(s->next_pic.f), | 67 | .BackwardRefIdx = ff_nvdec_get_ref_idx(s->next_pic.ptr ? s->next_pic.ptr->f : NULL), |
| 68 | .FrameWidth = cur_frame->width, | 68 | .FrameWidth = cur_frame->width, |
| 69 | .FrameHeight = cur_frame->height, | 69 | .FrameHeight = cur_frame->height, |
| 70 | 70 | ||
| @@ -40,10 +40,10 @@ void ff_write_pass1_stats(MpegEncContext *s) · 39 unmodified lines | |||
| 40 | snprintf(s->avctx->stats_out, 256, | 40 | snprintf(s->avctx->stats_out, 256, |
| 41 | "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d " | 41 | "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d " |
| 42 | "fcode:%d bcode:%d mc-var:%"PRId64" var:%"PRId64" icount:%d hbits:%d;\n", | 42 | "fcode:%d bcode:%d mc-var:%"PRId64" var:%"PRId64" icount:%d hbits:%d;\n", |
| 43 | s->cur_pic_ptr->display_picture_number, | 43 | s->cur_pic.ptr->display_picture_number, |
| 44 | s->cur_pic_ptr->coded_picture_number, | 44 | s->cur_pic.ptr->coded_picture_number, |
| 45 | s->pict_type, | 45 | s->pict_type, |
| 46 | s->cur_pic.f->quality, | 46 | s->cur_pic.ptr->f->quality, |
| 47 | s->i_tex_bits, | 47 | s->i_tex_bits, |
| 48 | s->p_tex_bits, | 48 | s->p_tex_bits, |
| 49 | s->mv_bits, | 49 | s->mv_bits, |
| @@ -936,9 +936,9 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run) · 886 unmodified lines | |||
| 936 | * here instead of reordering but the reordering is simpler for now | 936 | * here instead of reordering but the reordering is simpler for now |
| 937 | * until H.264 B-pyramid must be handled. */ | 937 | * until H.264 B-pyramid must be handled. */ |
| 938 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) | 938 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) |
| 939 | dts_pic = s->cur_pic_ptr; | 939 | dts_pic = s->cur_pic.ptr; |
| 940 | else | 940 | else |
| 941 | dts_pic = s->last_pic_ptr; | 941 | dts_pic = s->last_pic.ptr; |
| 942 | 942 | ||
| 943 | if (!dts_pic || dts_pic->f->pts == AV_NOPTS_VALUE) | 943 | if (!dts_pic || dts_pic->f->pts == AV_NOPTS_VALUE) |
| 944 | wanted_bits = (uint64_t)(s->bit_rate * (double)picture_number / fps); | 944 | wanted_bits = (uint64_t)(s->bit_rate * (double)picture_number / fps); |
| @@ -170,7 +170,7 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size) · 169 unmodified lines | |||
| 170 | av_log(s->avctx, AV_LOG_ERROR, "low delay B\n"); | 170 | av_log(s->avctx, AV_LOG_ERROR, "low delay B\n"); |
| 171 | return -1; | 171 | return -1; |
| 172 | } | 172 | } |
| 173 | if (!s->last_pic_ptr && s->pict_type == AV_PICTURE_TYPE_B) { | 173 | if (!s->last_pic.ptr && s->pict_type == AV_PICTURE_TYPE_B) { |
| 174 | av_log(s->avctx, AV_LOG_ERROR, "early B-frame\n"); | 174 | av_log(s->avctx, AV_LOG_ERROR, "early B-frame\n"); |
| 175 | return AVERROR_INVALIDDATA; | 175 | return AVERROR_INVALIDDATA; |
| 176 | } | 176 | } |
| @@ -458,9 +458,9 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, · 281 unmodified lines | |||
| 458 | if (whole_size < s->mb_width * s->mb_height / 8) | 458 | if (whole_size < s->mb_width * s->mb_height / 8) |
| 459 | return AVERROR_INVALIDDATA; | 459 | return AVERROR_INVALIDDATA; |
| 460 | 460 | ||
| 461 | if ((s->mb_x == 0 && s->mb_y == 0) || !s->cur_pic_ptr) { | 461 | if ((s->mb_x == 0 && s->mb_y == 0) || !s->cur_pic.ptr) { |
| 462 | // FIXME write parser so we always have complete frames? | 462 | // FIXME write parser so we always have complete frames? |
| 463 | if (s->cur_pic_ptr) { | 463 | if (s->cur_pic.ptr) { |
| 464 | ff_er_frame_end(&s->er, NULL); | 464 | ff_er_frame_end(&s->er, NULL); |
| 465 | ff_mpv_frame_end(s); | 465 | ff_mpv_frame_end(s); |
| 466 | s->mb_x = s->mb_y = s->resync_mb_x = s->resync_mb_y = 0; | 466 | s->mb_x = s->mb_y = s->resync_mb_x = s->resync_mb_y = 0; |
| @@ -469,7 +469,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, · 2 unmodified lines | |||
| 469 | return ret; | 469 | return ret; |
| 470 | ff_mpeg_er_frame_start(s); | 470 | ff_mpeg_er_frame_start(s); |
| 471 | } else { | 471 | } else { |
| 472 | if (s->cur_pic_ptr->f->pict_type != s->pict_type) { | 472 | if (s->cur_pic.ptr->f->pict_type != s->pict_type) { |
| 473 | av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n"); | 473 | av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n"); |
| 474 | return AVERROR_INVALIDDATA; | 474 | return AVERROR_INVALIDDATA; |
| 475 | } | 475 | } |
| @@ -632,28 +632,28 @@ static int rv10_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 156 unmodified lines | |||
| 632 | i++; | 632 | i++; |
| 633 | } | 633 | } |
| 634 | 634 | ||
| 635 | if (s->cur_pic_ptr && s->mb_y >= s->mb_height) { | 635 | if (s->cur_pic.ptr && s->mb_y >= s->mb_height) { |
| 636 | ff_er_frame_end(&s->er, NULL); | 636 | ff_er_frame_end(&s->er, NULL); |
| 637 | ff_mpv_frame_end(s); | 637 | ff_mpv_frame_end(s); |
| 638 | 638 | ||
| 639 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { | 639 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { |
| 640 | if ((ret = av_frame_ref(pict, s->cur_pic_ptr->f)) < 0) | 640 | if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0) |
| 641 | return ret; | 641 | return ret; |
| 642 | ff_print_debug_info(s, s->cur_pic_ptr, pict); | 642 | ff_print_debug_info(s, s->cur_pic.ptr, pict); |
| 643 | ff_mpv_export_qp_table(s, pict, s->cur_pic_ptr, FF_MPV_QSCALE_TYPE_MPEG1); | 643 | ff_mpv_export_qp_table(s, pict, s->cur_pic.ptr, FF_MPV_QSCALE_TYPE_MPEG1); |
| 644 | } else if (s->last_pic_ptr) { | 644 | } else if (s->last_pic.ptr) { |
| 645 | if ((ret = av_frame_ref(pict, s->last_pic_ptr->f)) < 0) | 645 | if ((ret = av_frame_ref(pict, s->last_pic.ptr->f)) < 0) |
| 646 | return ret; | 646 | return ret; |
| 647 | ff_print_debug_info(s, s->last_pic_ptr, pict); | 647 | ff_print_debug_info(s, s->last_pic.ptr, pict); |
| 648 | ff_mpv_export_qp_table(s, pict,s->last_pic_ptr, FF_MPV_QSCALE_TYPE_MPEG1); | 648 | ff_mpv_export_qp_table(s, pict,s->last_pic.ptr, FF_MPV_QSCALE_TYPE_MPEG1); |
| 649 | } | 649 | } |
| 650 | 650 | ||
| 651 | if (s->last_pic_ptr || s->low_delay) { | 651 | if (s->last_pic.ptr || s->low_delay) { |
| 652 | *got_frame = 1; | 652 | *got_frame = 1; |
| 653 | } | 653 | } |
| 654 | 654 | ||
| 655 | // so we can detect if frame_end was not called (find some nicer solution...) | 655 | // so we can detect if frame_end was not called (find some nicer solution...) |
| 656 | s->cur_pic_ptr = NULL; | 656 | s->cur_pic.ptr = NULL; |
| 657 | } | 657 | } |
| 658 | 658 | ||
| 659 | return avpkt->size; | 659 | return avpkt->size; |
| @@ -567,7 +567,7 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir) · 566 unmodified lines | |||
| 567 | int has_A = 0, has_B = 0, has_C = 0; | 567 | int has_A = 0, has_B = 0, has_C = 0; |
| 568 | int mx, my; | 568 | int mx, my; |
| 569 | int i, j; | 569 | int i, j; |
| 570 | MPVPicture *cur_pic = &s->cur_pic; | 570 | MPVWorkPicture *cur_pic = &s->cur_pic; |
| 571 | const int mask = dir ? MB_TYPE_L1 : MB_TYPE_L0; | 571 | const int mask = dir ? MB_TYPE_L1 : MB_TYPE_L0; |
| 572 | int type = cur_pic->mb_type[mb_pos]; | 572 | int type = cur_pic->mb_type[mb_pos]; |
| 573 | 573 | ||
| @@ -721,7 +721,7 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type, · 147 unmodified lines | |||
| 721 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) { | 721 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) { |
| 722 | /* wait for the referenced mb row to be finished */ | 722 | /* wait for the referenced mb row to be finished */ |
| 723 | int mb_row = s->mb_y + ((yoff + my + 5 + 8 * height) >> 4); | 723 | int mb_row = s->mb_y + ((yoff + my + 5 + 8 * height) >> 4); |
| 724 | const ThreadFrame *f = dir ? &s->next_pic_ptr->tf : &s->last_pic_ptr->tf; | 724 | const ThreadFrame *f = dir ? &s->next_pic.ptr->tf : &s->last_pic.ptr->tf; |
| 725 | ff_thread_await_progress(f, mb_row, 0); | 725 | ff_thread_await_progress(f, mb_row, 0); |
| 726 | } | 726 | } |
| 727 | 727 | ||
| @@ -901,7 +901,7 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type) · 173 unmodified lines | |||
| 901 | //surprisingly, it uses motion scheme from next reference frame | 901 | //surprisingly, it uses motion scheme from next reference frame |
| 902 | /* wait for the current mb row to be finished */ | 902 | /* wait for the current mb row to be finished */ |
| 903 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) | 903 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) |
| 904 | ff_thread_await_progress(&s->next_pic_ptr->tf, FFMAX(0, s->mb_y-1), 0); | 904 | ff_thread_await_progress(&s->next_pic.ptr->tf, FFMAX(0, s->mb_y-1), 0); |
| 905 | 905 | ||
| 906 | next_bt = s->next_pic.mb_type[s->mb_x + s->mb_y * s->mb_stride]; | 906 | next_bt = s->next_pic.mb_type[s->mb_x + s->mb_y * s->mb_stride]; |
| 907 | if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){ | 907 | if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){ |
| @@ -1485,7 +1485,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int · 577 unmodified lines | |||
| 1485 | r->loop_filter(r, s->mb_y - 2); | 1485 | r->loop_filter(r, s->mb_y - 2); |
| 1486 | 1486 | ||
| 1487 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) | 1487 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) |
| 1488 | ff_thread_report_progress(&s->cur_pic_ptr->tf, | 1488 | ff_thread_report_progress(&s->cur_pic.ptr->tf, |
| 1489 | s->mb_y - 2, 0); | 1489 | s->mb_y - 2, 0); |
| 1490 | 1490 | ||
| 1491 | } | 1491 | } |
| @@ -1583,19 +1583,19 @@ static int finish_frame(AVCodecContext *avctx, AVFrame *pict) · 91 unmodified lines | |||
| 1583 | s->mb_num_left = 0; | 1583 | s->mb_num_left = 0; |
| 1584 | 1584 | ||
| 1585 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) | 1585 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) |
| 1586 | ff_thread_report_progress(&s->cur_pic_ptr->tf, INT_MAX, 0); | 1586 | ff_thread_report_progress(&s->cur_pic.ptr->tf, INT_MAX, 0); |
| 1587 | 1587 | ||
| 1588 | if (s->pict_type == AV_PICTURE_TYPE_B) { | 1588 | if (s->pict_type == AV_PICTURE_TYPE_B) { |
| 1589 | if ((ret = av_frame_ref(pict, s->cur_pic_ptr->f)) < 0) | 1589 | if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0) |
| 1590 | return ret; | 1590 | return ret; |
| 1591 | ff_print_debug_info(s, s->cur_pic_ptr, pict); | 1591 | ff_print_debug_info(s, s->cur_pic.ptr, pict); |
| 1592 | ff_mpv_export_qp_table(s, pict, s->cur_pic_ptr, FF_MPV_QSCALE_TYPE_MPEG1); | 1592 | ff_mpv_export_qp_table(s, pict, s->cur_pic.ptr, FF_MPV_QSCALE_TYPE_MPEG1); |
| 1593 | got_picture = 1; | 1593 | got_picture = 1; |
| 1594 | } else if (s->last_pic_ptr) { | 1594 | } else if (s->last_pic.ptr) { |
| 1595 | if ((ret = av_frame_ref(pict, s->last_pic_ptr->f)) < 0) | 1595 | if ((ret = av_frame_ref(pict, s->last_pic.ptr->f)) < 0) |
| 1596 | return ret; | 1596 | return ret; |
| 1597 | ff_print_debug_info(s, s->last_pic_ptr, pict); | 1597 | ff_print_debug_info(s, s->last_pic.ptr, pict); |
| 1598 | ff_mpv_export_qp_table(s, pict, s->last_pic_ptr, FF_MPV_QSCALE_TYPE_MPEG1); | 1598 | ff_mpv_export_qp_table(s, pict, s->last_pic.ptr, FF_MPV_QSCALE_TYPE_MPEG1); |
| 1599 | got_picture = 1; | 1599 | got_picture = 1; |
| 1600 | } | 1600 | } |
| 1601 | 1601 | ||
| @@ -1630,10 +1630,10 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 28 unmodified lines | |||
| 1630 | /* no supplementary picture */ | 1630 | /* no supplementary picture */ |
| 1631 | if (buf_size == 0) { | 1631 | if (buf_size == 0) { |
| 1632 | /* special case for last picture */ | 1632 | /* special case for last picture */ |
| 1633 | if (s->next_pic_ptr) { | 1633 | if (s->next_pic.ptr) { |
| 1634 | if ((ret = av_frame_ref(pict, s->next_pic_ptr->f)) < 0) | 1634 | if ((ret = av_frame_ref(pict, s->next_pic.ptr->f)) < 0) |
| 1635 | return ret; | 1635 | return ret; |
| 1636 | s->next_pic_ptr = NULL; | 1636 | s->next_pic.ptr = NULL; |
| 1637 | 1637 | ||
| 1638 | *got_picture_ptr = 1; | 1638 | *got_picture_ptr = 1; |
| 1639 | } | 1639 | } |
| @@ -1656,7 +1656,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 16 unmodified lines | |||
| 1656 | av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n"); | 1656 | av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n"); |
| 1657 | return AVERROR_INVALIDDATA; | 1657 | return AVERROR_INVALIDDATA; |
| 1658 | } | 1658 | } |
| 1659 | if ((!s->last_pic_ptr || !s->last_pic_ptr->f->data[0]) && | 1659 | if ((!s->last_pic.ptr || !s->last_pic.ptr->f->data[0]) && |
| 1660 | si.type == AV_PICTURE_TYPE_B) { | 1660 | si.type == AV_PICTURE_TYPE_B) { |
| 1661 | av_log(avctx, AV_LOG_ERROR, "Invalid decoder state: B-frame without " | 1661 | av_log(avctx, AV_LOG_ERROR, "Invalid decoder state: B-frame without " |
| 1662 | "reference data.\n"); | 1662 | "reference data.\n"); |
| @@ -1669,7 +1669,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 6 unmodified lines | |||
| 1669 | 1669 | ||
| 1670 | /* first slice */ | 1670 | /* first slice */ |
| 1671 | if (si.start == 0) { | 1671 | if (si.start == 0) { |
| 1672 | if (s->mb_num_left > 0 && s->cur_pic_ptr) { | 1672 | if (s->mb_num_left > 0 && s->cur_pic.ptr) { |
| 1673 | av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.\n", | 1673 | av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.\n", |
| 1674 | s->mb_num_left); | 1674 | s->mb_num_left); |
| 1675 | if (!s->context_reinit) | 1675 | if (!s->context_reinit) |
| @@ -1794,7 +1794,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 118 unmodified lines | |||
| 1794 | break; | 1794 | break; |
| 1795 | } | 1795 | } |
| 1796 | 1796 | ||
| 1797 | if (s->cur_pic_ptr) { | 1797 | if (s->cur_pic.ptr) { |
| 1798 | if (last) { | 1798 | if (last) { |
| 1799 | if(r->loop_filter) | 1799 | if(r->loop_filter) |
| 1800 | r->loop_filter(r, s->mb_height - 1); | 1800 | r->loop_filter(r, s->mb_height - 1); |
| @@ -1811,7 +1811,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 10 unmodified lines | |||
| 1811 | ff_er_frame_end(&s->er, NULL); | 1811 | ff_er_frame_end(&s->er, NULL); |
| 1812 | ff_mpv_frame_end(s); | 1812 | ff_mpv_frame_end(s); |
| 1813 | s->mb_num_left = 0; | 1813 | s->mb_num_left = 0; |
| 1814 | ff_thread_report_progress(&s->cur_pic_ptr->tf, INT_MAX, 0); | 1814 | ff_thread_report_progress(&s->cur_pic.ptr->tf, INT_MAX, 0); |
| 1815 | return AVERROR_INVALIDDATA; | 1815 | return AVERROR_INVALIDDATA; |
| 1816 | } | 1816 | } |
| 1817 | } | 1817 | } |
| @@ -62,6 +62,7 @@ typedef struct SnowEncContext { · 61 unmodified lines | |||
| 62 | 62 | ||
| 63 | MECmpContext mecc; | 63 | MECmpContext mecc; |
| 64 | MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX) | 64 | MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX) |
| 65 | MPVPicture cur_pic, last_pic; | ||
| 65 | #define ME_CACHE_SIZE 1024 | 66 | #define ME_CACHE_SIZE 1024 |
| 66 | unsigned me_cache[ME_CACHE_SIZE]; | 67 | unsigned me_cache[ME_CACHE_SIZE]; |
| 67 | unsigned me_cache_generation; | 68 | unsigned me_cache_generation; |
| @@ -1834,9 +1835,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 1766 unmodified lines | |||
| 1834 | if (ret < 0) | 1835 | if (ret < 0) |
| 1835 | return ret; | 1836 | return ret; |
| 1836 | 1837 | ||
| 1837 | mpv->cur_pic_ptr = &mpv->cur_pic; | 1838 | mpv->cur_pic.ptr = &enc->cur_pic; |
| 1838 | mpv->cur_pic.f = s->current_picture; | 1839 | mpv->cur_pic.ptr->f = s->current_picture; |
| 1839 | mpv->cur_pic.f->pts = pict->pts; | 1840 | mpv->cur_pic.ptr->f->pts = pict->pts; |
| 1840 | if(pic->pict_type == AV_PICTURE_TYPE_P){ | 1841 | if(pic->pict_type == AV_PICTURE_TYPE_P){ |
| 1841 | int block_width = (width +15)>>4; | 1842 | int block_width = (width +15)>>4; |
| 1842 | int block_height= (height+15)>>4; | 1843 | int block_height= (height+15)>>4; |
| @@ -1846,9 +1847,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 3 unmodified lines | |||
| 1846 | av_assert0(s->last_picture[0]->data[0]); | 1847 | av_assert0(s->last_picture[0]->data[0]); |
| 1847 | 1848 | ||
| 1848 | mpv->avctx = s->avctx; | 1849 | mpv->avctx = s->avctx; |
| 1849 | mpv->last_pic.f = s->last_picture[0]; | 1850 | mpv->last_pic.ptr = &enc->last_pic; |
| 1851 | mpv->last_pic.ptr->f = s->last_picture[0]; | ||
| 1850 | mpv-> new_pic = s->input_picture; | 1852 | mpv-> new_pic = s->input_picture; |
| 1851 | mpv->last_pic_ptr = &mpv->last_pic; | ||
| 1852 | mpv->linesize = stride; | 1853 | mpv->linesize = stride; |
| 1853 | mpv->uvlinesize = s->current_picture->linesize[1]; | 1854 | mpv->uvlinesize = s->current_picture->linesize[1]; |
| 1854 | mpv->width = width; | 1855 | mpv->width = width; |
| @@ -2043,9 +2044,9 @@ redo_frame: · 188 unmodified lines | |||
| 2043 | mpv->frame_bits = 8 * (s->c.bytestream - s->c.bytestream_start); | 2044 | mpv->frame_bits = 8 * (s->c.bytestream - s->c.bytestream_start); |
| 2044 | mpv->p_tex_bits = mpv->frame_bits - mpv->misc_bits - mpv->mv_bits; | 2045 | mpv->p_tex_bits = mpv->frame_bits - mpv->misc_bits - mpv->mv_bits; |
| 2045 | mpv->total_bits += 8*(s->c.bytestream - s->c.bytestream_start); | 2046 | mpv->total_bits += 8*(s->c.bytestream - s->c.bytestream_start); |
| 2046 | mpv->cur_pic.display_picture_number = | 2047 | enc->cur_pic.display_picture_number = |
| 2047 | mpv->cur_pic.coded_picture_number = avctx->frame_num; | 2048 | enc->cur_pic.coded_picture_number = avctx->frame_num; |
| 2048 | mpv->cur_pic.f->quality = pic->quality; | 2049 | enc->cur_pic.f->quality = pic->quality; |
| 2049 | if (enc->pass1_rc) | 2050 | if (enc->pass1_rc) |
| 2050 | if (ff_rate_estimate_qscale(mpv, 0) < 0) | 2051 | if (ff_rate_estimate_qscale(mpv, 0) < 0) |
| 2051 | return -1; | 2052 | return -1; |
| @@ -60,6 +60,7 @@ typedef struct SVQ1EncContext { · 59 unmodified lines | |||
| 60 | * else, the idea is to make the motion estimation eventually independent | 60 | * else, the idea is to make the motion estimation eventually independent |
| 61 | * of MpegEncContext, so this will be removed then. */ | 61 | * of MpegEncContext, so this will be removed then. */ |
| 62 | MpegEncContext m; | 62 | MpegEncContext m; |
| 63 | MPVPicture cur_pic, last_pic; | ||
| 63 | AVCodecContext *avctx; | 64 | AVCodecContext *avctx; |
| 64 | MECmpContext mecc; | 65 | MECmpContext mecc; |
| 65 | HpelDSPContext hdsp; | 66 | HpelDSPContext hdsp; |
| @@ -326,8 +327,8 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, · 260 unmodified lines | |||
| 326 | 327 | ||
| 327 | if (s->pict_type == AV_PICTURE_TYPE_P) { | 328 | if (s->pict_type == AV_PICTURE_TYPE_P) { |
| 328 | s->m.avctx = s->avctx; | 329 | s->m.avctx = s->avctx; |
| 329 | s->m.cur_pic_ptr = &s->m.cur_pic; | 330 | s->m.cur_pic.ptr = &s->cur_pic; |
| 330 | s->m.last_pic_ptr = &s->m.last_pic; | 331 | s->m.last_pic.ptr = &s->last_pic; |
| 331 | s->m.last_pic.data[0] = ref_plane; | 332 | s->m.last_pic.data[0] = ref_plane; |
| 332 | s->m.linesize = | 333 | s->m.linesize = |
| 333 | s->m.last_pic.linesize[0] = | 334 | s->m.last_pic.linesize[0] = |
| @@ -42,12 +42,12 @@ static inline int mpeg2_get_is_frame_start(const MpegEncContext *s) · 41 unmodified lines | |||
| 42 | static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) | 42 | static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) |
| 43 | { | 43 | { |
| 44 | const MpegEncContext *s = avctx->priv_data; | 44 | const MpegEncContext *s = avctx->priv_data; |
| 45 | VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; | 45 | VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 46 | VAPictureParameterBufferMPEG2 pic_param; | 46 | VAPictureParameterBufferMPEG2 pic_param; |
| 47 | VAIQMatrixBufferMPEG2 iq_matrix; | 47 | VAIQMatrixBufferMPEG2 iq_matrix; |
| 48 | int i, err; | 48 | int i, err; |
| 49 | 49 | ||
| 50 | pic->output_surface = ff_vaapi_get_surface_id(s->cur_pic_ptr->f); | 50 | pic->output_surface = ff_vaapi_get_surface_id(s->cur_pic.ptr->f); |
| 51 | 51 | ||
| 52 | pic_param = (VAPictureParameterBufferMPEG2) { | 52 | pic_param = (VAPictureParameterBufferMPEG2) { |
| 53 | .horizontal_size = s->width, | 53 | .horizontal_size = s->width, |
| @@ -73,10 +73,10 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_ · 19 unmodified lines | |||
| 73 | 73 | ||
| 74 | switch (s->pict_type) { | 74 | switch (s->pict_type) { |
| 75 | case AV_PICTURE_TYPE_B: | 75 | case AV_PICTURE_TYPE_B: |
| 76 | pic_param.backward_reference_picture = ff_vaapi_get_surface_id(s->next_pic.f); | 76 | pic_param.backward_reference_picture = ff_vaapi_get_surface_id(s->next_pic.ptr->f); |
| 77 | // fall-through | 77 | // fall-through |
| 78 | case AV_PICTURE_TYPE_P: | 78 | case AV_PICTURE_TYPE_P: |
| 79 | pic_param.forward_reference_picture = ff_vaapi_get_surface_id(s->last_pic.f); | 79 | pic_param.forward_reference_picture = ff_vaapi_get_surface_id(s->last_pic.ptr->f); |
| 80 | break; | 80 | break; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| @@ -115,7 +115,7 @@ fail: · 32 unmodified lines | |||
| 115 | static int vaapi_mpeg2_end_frame(AVCodecContext *avctx) | 115 | static int vaapi_mpeg2_end_frame(AVCodecContext *avctx) |
| 116 | { | 116 | { |
| 117 | MpegEncContext *s = avctx->priv_data; | 117 | MpegEncContext *s = avctx->priv_data; |
| 118 | VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; | 118 | VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 119 | int ret; | 119 | int ret; |
| 120 | 120 | ||
| 121 | ret = ff_vaapi_decode_issue(avctx, pic); | 121 | ret = ff_vaapi_decode_issue(avctx, pic); |
| @@ -131,7 +131,7 @@ fail: · 9 unmodified lines | |||
| 131 | static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | 131 | static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) |
| 132 | { | 132 | { |
| 133 | const MpegEncContext *s = avctx->priv_data; | 133 | const MpegEncContext *s = avctx->priv_data; |
| 134 | VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; | 134 | VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 135 | VASliceParameterBufferMPEG2 slice_param; | 135 | VASliceParameterBufferMPEG2 slice_param; |
| 136 | GetBitContext gb; | 136 | GetBitContext gb; |
| 137 | uint32_t quantiser_scale_code, intra_slice_flag, macroblock_offset; | 137 | uint32_t quantiser_scale_code, intra_slice_flag, macroblock_offset; |
| @@ -49,11 +49,11 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ · 48 unmodified lines | |||
| 49 | { | 49 | { |
| 50 | Mpeg4DecContext *ctx = avctx->priv_data; | 50 | Mpeg4DecContext *ctx = avctx->priv_data; |
| 51 | MpegEncContext *s = &ctx->m; | 51 | MpegEncContext *s = &ctx->m; |
| 52 | VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; | 52 | VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 53 | VAPictureParameterBufferMPEG4 pic_param; | 53 | VAPictureParameterBufferMPEG4 pic_param; |
| 54 | int i, err; | 54 | int i, err; |
| 55 | 55 | ||
| 56 | pic->output_surface = ff_vaapi_get_surface_id(s->cur_pic_ptr->f); | 56 | pic->output_surface = ff_vaapi_get_surface_id(s->cur_pic.ptr->f); |
| 57 | 57 | ||
| 58 | pic_param = (VAPictureParameterBufferMPEG4) { | 58 | pic_param = (VAPictureParameterBufferMPEG4) { |
| 59 | .vop_width = s->width, | 59 | .vop_width = s->width, |
| @@ -78,7 +78,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ · 18 unmodified lines | |||
| 78 | .vop_fields.bits = { | 78 | .vop_fields.bits = { |
| 79 | .vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I, | 79 | .vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I, |
| 80 | .backward_reference_vop_coding_type = | 80 | .backward_reference_vop_coding_type = |
| 81 | s->pict_type == AV_PICTURE_TYPE_B ? s->next_pic.f->pict_type - AV_PICTURE_TYPE_I : 0, | 81 | s->pict_type == AV_PICTURE_TYPE_B ? s->next_pic.ptr->f->pict_type - AV_PICTURE_TYPE_I : 0, |
| 82 | .vop_rounding_type = s->no_rounding, | 82 | .vop_rounding_type = s->no_rounding, |
| 83 | .intra_dc_vlc_thr = mpeg4_get_intra_dc_vlc_thr(ctx), | 83 | .intra_dc_vlc_thr = mpeg4_get_intra_dc_vlc_thr(ctx), |
| 84 | .top_field_first = s->top_field_first, | 84 | .top_field_first = s->top_field_first, |
| @@ -100,9 +100,9 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ · 15 unmodified lines | |||
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | if (s->pict_type == AV_PICTURE_TYPE_B) | 102 | if (s->pict_type == AV_PICTURE_TYPE_B) |
| 103 | pic_param.backward_reference_picture = ff_vaapi_get_surface_id(s->next_pic.f); | 103 | pic_param.backward_reference_picture = ff_vaapi_get_surface_id(s->next_pic.ptr->f); |
| 104 | if (s->pict_type != AV_PICTURE_TYPE_I) | 104 | if (s->pict_type != AV_PICTURE_TYPE_I) |
| 105 | pic_param.forward_reference_picture = ff_vaapi_get_surface_id(s->last_pic.f); | 105 | pic_param.forward_reference_picture = ff_vaapi_get_surface_id(s->last_pic.ptr->f); |
| 106 | 106 | ||
| 107 | err = ff_vaapi_decode_make_param_buffer(avctx, pic, | 107 | err = ff_vaapi_decode_make_param_buffer(avctx, pic, |
| 108 | VAPictureParameterBufferType, | 108 | VAPictureParameterBufferType, |
| @@ -139,7 +139,7 @@ fail: · 30 unmodified lines | |||
| 139 | static int vaapi_mpeg4_end_frame(AVCodecContext *avctx) | 139 | static int vaapi_mpeg4_end_frame(AVCodecContext *avctx) |
| 140 | { | 140 | { |
| 141 | MpegEncContext *s = avctx->priv_data; | 141 | MpegEncContext *s = avctx->priv_data; |
| 142 | VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; | 142 | VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 143 | int ret; | 143 | int ret; |
| 144 | 144 | ||
| 145 | ret = ff_vaapi_decode_issue(avctx, pic); | 145 | ret = ff_vaapi_decode_issue(avctx, pic); |
| @@ -155,7 +155,7 @@ fail: · 9 unmodified lines | |||
| 155 | static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | 155 | static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) |
| 156 | { | 156 | { |
| 157 | MpegEncContext *s = avctx->priv_data; | 157 | MpegEncContext *s = avctx->priv_data; |
| 158 | VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; | 158 | VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 159 | VASliceParameterBufferMPEG4 slice_param; | 159 | VASliceParameterBufferMPEG4 slice_param; |
| 160 | int err; | 160 | int err; |
| 161 | 161 | ||
| @@ -253,11 +253,11 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t · 252 unmodified lines | |||
| 253 | { | 253 | { |
| 254 | const VC1Context *v = avctx->priv_data; | 254 | const VC1Context *v = avctx->priv_data; |
| 255 | const MpegEncContext *s = &v->s; | 255 | const MpegEncContext *s = &v->s; |
| 256 | VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; | 256 | VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 257 | VAPictureParameterBufferVC1 pic_param; | 257 | VAPictureParameterBufferVC1 pic_param; |
| 258 | int err; | 258 | int err; |
| 259 | 259 | ||
| 260 | pic->output_surface = ff_vaapi_get_surface_id(s->cur_pic_ptr->f); | 260 | pic->output_surface = ff_vaapi_get_surface_id(s->cur_pic.ptr->f); |
| 261 | 261 | ||
| 262 | pic_param = (VAPictureParameterBufferVC1) { | 262 | pic_param = (VAPictureParameterBufferVC1) { |
| 263 | .forward_reference_picture = VA_INVALID_ID, | 263 | .forward_reference_picture = VA_INVALID_ID, |
| @@ -374,10 +374,12 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t · 110 unmodified lines | |||
| 374 | 374 | ||
| 375 | switch (s->pict_type) { | 375 | switch (s->pict_type) { |
| 376 | case AV_PICTURE_TYPE_B: | 376 | case AV_PICTURE_TYPE_B: |
| 377 | pic_param.backward_reference_picture = ff_vaapi_get_surface_id(s->next_pic.f); | 377 | if (s->next_pic.ptr) |
| 378 | pic_param.backward_reference_picture = ff_vaapi_get_surface_id(s->next_pic.ptr->f); | ||
| 378 | // fall-through | 379 | // fall-through |
| 379 | case AV_PICTURE_TYPE_P: | 380 | case AV_PICTURE_TYPE_P: |
| 380 | pic_param.forward_reference_picture = ff_vaapi_get_surface_id(s->last_pic.f); | 381 | if (s->last_pic.ptr) |
| 382 | pic_param.forward_reference_picture = ff_vaapi_get_surface_id(s->last_pic.ptr->f); | ||
| 381 | break; | 383 | break; |
| 382 | } | 384 | } |
| 383 | 385 | ||
| @@ -450,7 +452,7 @@ static int vaapi_vc1_end_frame(AVCodecContext *avctx) · 66 unmodified lines | |||
| 450 | { | 452 | { |
| 451 | VC1Context *v = avctx->priv_data; | 453 | VC1Context *v = avctx->priv_data; |
| 452 | MpegEncContext *s = &v->s; | 454 | MpegEncContext *s = &v->s; |
| 453 | VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; | 455 | VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 454 | int ret; | 456 | int ret; |
| 455 | 457 | ||
| 456 | ret = ff_vaapi_decode_issue(avctx, pic); | 458 | ret = ff_vaapi_decode_issue(avctx, pic); |
| @@ -465,7 +467,7 @@ static int vaapi_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, · 8 unmodified lines | |||
| 465 | { | 467 | { |
| 466 | const VC1Context *v = avctx->priv_data; | 468 | const VC1Context *v = avctx->priv_data; |
| 467 | const MpegEncContext *s = &v->s; | 469 | const MpegEncContext *s = &v->s; |
| 468 | VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; | 470 | VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; |
| 469 | VASliceParameterBufferVC1 slice_param; | 471 | VASliceParameterBufferVC1 slice_param; |
| 470 | int mb_height; | 472 | int mb_height; |
| 471 | int err; | 473 | int err; |
| @@ -856,7 +856,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) · 855 unmodified lines | |||
| 856 | v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; | 856 | v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; |
| 857 | else | 857 | else |
| 858 | v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; | 858 | v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; |
| 859 | v->s.cur_pic_ptr->f->pict_type = v->s.pict_type; | 859 | v->s.cur_pic.ptr->f->pict_type = v->s.pict_type; |
| 860 | if (!v->pic_header_flag) | 860 | if (!v->pic_header_flag) |
| 861 | goto parse_common_info; | 861 | goto parse_common_info; |
| 862 | } | 862 | } |
| @@ -59,9 +59,9 @@ static inline void init_block_index(VC1Context *v) · 58 unmodified lines | |||
| 59 | MpegEncContext *s = &v->s; | 59 | MpegEncContext *s = &v->s; |
| 60 | ff_init_block_index(s); | 60 | ff_init_block_index(s); |
| 61 | if (v->field_mode && !(v->second_field ^ v->tff)) { | 61 | if (v->field_mode && !(v->second_field ^ v->tff)) { |
| 62 | s->dest[0] += s->cur_pic_ptr->f->linesize[0]; | 62 | s->dest[0] += s->cur_pic.ptr->f->linesize[0]; |
| 63 | s->dest[1] += s->cur_pic_ptr->f->linesize[1]; | 63 | s->dest[1] += s->cur_pic.ptr->f->linesize[1]; |
| 64 | s->dest[2] += s->cur_pic_ptr->f->linesize[2]; | 64 | s->dest[2] += s->cur_pic.ptr->f->linesize[2]; |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | 67 | ||
| @@ -2101,7 +2101,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v) · 2033 unmodified lines | |||
| 2101 | if (bmvtype == BMV_TYPE_DIRECT) { | 2101 | if (bmvtype == BMV_TYPE_DIRECT) { |
| 2102 | dmv_x[0] = dmv_y[0] = pred_flag[0] = 0; | 2102 | dmv_x[0] = dmv_y[0] = pred_flag[0] = 0; |
| 2103 | dmv_x[1] = dmv_y[1] = pred_flag[0] = 0; | 2103 | dmv_x[1] = dmv_y[1] = pred_flag[0] = 0; |
| 2104 | if (!s->next_pic_ptr->field_picture) { | 2104 | if (!s->next_pic.ptr->field_picture) { |
| 2105 | av_log(s->avctx, AV_LOG_ERROR, "Mixed field/frame direct mode not supported\n"); | 2105 | av_log(s->avctx, AV_LOG_ERROR, "Mixed field/frame direct mode not supported\n"); |
| 2106 | return AVERROR_INVALIDDATA; | 2106 | return AVERROR_INVALIDDATA; |
| 2107 | } | 2107 | } |
| @@ -2267,7 +2267,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) · 159 unmodified lines | |||
| 2267 | direct = v->direct_mb_plane[mb_pos]; | 2267 | direct = v->direct_mb_plane[mb_pos]; |
| 2268 | 2268 | ||
| 2269 | if (direct) { | 2269 | if (direct) { |
| 2270 | if (s->next_pic_ptr->field_picture) | 2270 | if (s->next_pic.ptr->field_picture) |
| 2271 | av_log(s->avctx, AV_LOG_WARNING, "Mixed frame/field direct mode not supported\n"); | 2271 | av_log(s->avctx, AV_LOG_WARNING, "Mixed frame/field direct mode not supported\n"); |
| 2272 | s->mv[0][0][0] = s->cur_pic.motion_val[0][s->block_index[0]][0] = scale_mv(s->next_pic.motion_val[1][s->block_index[0]][0], v->bfraction, 0, s->quarter_sample); | 2272 | s->mv[0][0][0] = s->cur_pic.motion_val[0][s->block_index[0]][0] = scale_mv(s->next_pic.motion_val[1][s->block_index[0]][0], v->bfraction, 0, s->quarter_sample); |
| 2273 | s->mv[0][0][1] = s->cur_pic.motion_val[0][s->block_index[0]][1] = scale_mv(s->next_pic.motion_val[1][s->block_index[0]][1], v->bfraction, 0, s->quarter_sample); | 2273 | s->mv[0][0][1] = s->cur_pic.motion_val[0][s->block_index[0]][1] = scale_mv(s->next_pic.motion_val[1][s->block_index[0]][1], v->bfraction, 0, s->quarter_sample); |
| @@ -2964,7 +2964,7 @@ void ff_vc1_decode_blocks(VC1Context *v) · 690 unmodified lines | |||
| 2964 | 2964 | ||
| 2965 | v->s.esc3_level_length = 0; | 2965 | v->s.esc3_level_length = 0; |
| 2966 | if (v->x8_type) { | 2966 | if (v->x8_type) { |
| 2967 | ff_intrax8_decode_picture(&v->x8, &v->s.cur_pic, | 2967 | ff_intrax8_decode_picture(&v->x8, v->s.cur_pic.ptr, |
| 2968 | &v->s.gb, &v->s.mb_x, &v->s.mb_y, | 2968 | &v->s.gb, &v->s.mb_x, &v->s.mb_y, |
| 2969 | 2 * v->pq + v->halfpq, v->pq * !v->pquantizer, | 2969 | 2 * v->pq + v->halfpq, v->pq * !v->pquantizer, |
| 2970 | v->s.loop_filter, v->s.low_delay); | 2970 | v->s.loop_filter, v->s.low_delay); |
| @@ -187,8 +187,8 @@ void ff_vc1_mc_1mv(VC1Context *v, int dir) · 186 unmodified lines | |||
| 187 | !v->s.last_pic.data[0]) | 187 | !v->s.last_pic.data[0]) |
| 188 | return; | 188 | return; |
| 189 | 189 | ||
| 190 | linesize = s->cur_pic_ptr->f->linesize[0]; | 190 | linesize = s->cur_pic.ptr->f->linesize[0]; |
| 191 | uvlinesize = s->cur_pic_ptr->f->linesize[1]; | 191 | uvlinesize = s->cur_pic.ptr->f->linesize[1]; |
| 192 | 192 | ||
| 193 | mx = s->mv[dir][0][0]; | 193 | mx = s->mv[dir][0][0]; |
| 194 | my = s->mv[dir][0][1]; | 194 | my = s->mv[dir][0][1]; |
| @@ -467,7 +467,7 @@ void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) · 272 unmodified lines | |||
| 467 | !v->s.last_pic.data[0]) | 467 | !v->s.last_pic.data[0]) |
| 468 | return; | 468 | return; |
| 469 | 469 | ||
| 470 | linesize = s->cur_pic_ptr->f->linesize[0]; | 470 | linesize = s->cur_pic.ptr->f->linesize[0]; |
| 471 | 471 | ||
| 472 | mx = s->mv[dir][n][0]; | 472 | mx = s->mv[dir][n][0]; |
| 473 | my = s->mv[dir][n][1]; | 473 | my = s->mv[dir][n][1]; |
| @@ -669,7 +669,7 @@ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir) · 195 unmodified lines | |||
| 669 | s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx; | 669 | s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx; |
| 670 | s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty; | 670 | s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty; |
| 671 | 671 | ||
| 672 | uvlinesize = s->cur_pic_ptr->f->linesize[1]; | 672 | uvlinesize = s->cur_pic.ptr->f->linesize[1]; |
| 673 | 673 | ||
| 674 | uvmx = (tx + ((tx & 3) == 3)) >> 1; | 674 | uvmx = (tx + ((tx & 3) == 3)) >> 1; |
| 675 | uvmy = (ty + ((ty & 3) == 3)) >> 1; | 675 | uvmy = (ty + ((ty & 3) == 3)) >> 1; |
| @@ -856,7 +856,7 @@ void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg) · 180 unmodified lines | |||
| 856 | if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) | 856 | if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) |
| 857 | return; | 857 | return; |
| 858 | 858 | ||
| 859 | uvlinesize = s->cur_pic_ptr->f->linesize[1]; | 859 | uvlinesize = s->cur_pic.ptr->f->linesize[1]; |
| 860 | 860 | ||
| 861 | for (i = 0; i < 4; i++) { | 861 | for (i = 0; i < 4; i++) { |
| 862 | int d = i < 2 ? dir: dir2; | 862 | int d = i < 2 ? dir: dir2; |
| @@ -1015,8 +1015,8 @@ void ff_vc1_interp_mc(VC1Context *v) · 152 unmodified lines | |||
| 1015 | if (!v->field_mode && !v->s.next_pic.data[0]) | 1015 | if (!v->field_mode && !v->s.next_pic.data[0]) |
| 1016 | return; | 1016 | return; |
| 1017 | 1017 | ||
| 1018 | linesize = s->cur_pic_ptr->f->linesize[0]; | 1018 | linesize = s->cur_pic.ptr->f->linesize[0]; |
| 1019 | uvlinesize = s->cur_pic_ptr->f->linesize[1]; | 1019 | uvlinesize = s->cur_pic.ptr->f->linesize[1]; |
| 1020 | 1020 | ||
| 1021 | mx = s->mv[1][0][0]; | 1021 | mx = s->mv[1][0][0]; |
| 1022 | my = s->mv[1][0][1]; | 1022 | my = s->mv[1][0][1]; |
| @@ -719,7 +719,7 @@ void ff_vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], · 718 unmodified lines | |||
| 719 | s->cur_pic.motion_val[1][xy][1] = 0; | 719 | s->cur_pic.motion_val[1][xy][1] = 0; |
| 720 | return; | 720 | return; |
| 721 | } | 721 | } |
| 722 | if (direct && s->next_pic_ptr->field_picture) | 722 | if (direct && s->next_pic.ptr->field_picture) |
| 723 | av_log(s->avctx, AV_LOG_WARNING, "Mixed frame/field direct mode not supported\n"); | 723 | av_log(s->avctx, AV_LOG_WARNING, "Mixed frame/field direct mode not supported\n"); |
| 724 | 724 | ||
| 725 | s->mv[0][0][0] = scale_mv(s->next_pic.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample); | 725 | s->mv[0][0][0] = scale_mv(s->next_pic.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample); |
| @@ -322,7 +322,7 @@ static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb) · 321 unmodified lines | |||
| 322 | return AVERROR_UNKNOWN; | 322 | return AVERROR_UNKNOWN; |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | if (v->two_sprites && (!s->last_pic_ptr || !s->last_pic.data[0])) { | 325 | if (v->two_sprites && (!s->last_pic.ptr || !s->last_pic.data[0])) { |
| 326 | av_log(avctx, AV_LOG_WARNING, "Need two sprites, only got one\n"); | 326 | av_log(avctx, AV_LOG_WARNING, "Need two sprites, only got one\n"); |
| 327 | v->two_sprites = 0; | 327 | v->two_sprites = 0; |
| 328 | } | 328 | } |
| @@ -340,7 +340,7 @@ static void vc1_sprite_flush(AVCodecContext *avctx) · 11 unmodified lines | |||
| 340 | { | 340 | { |
| 341 | VC1Context *v = avctx->priv_data; | 341 | VC1Context *v = avctx->priv_data; |
| 342 | MpegEncContext *s = &v->s; | 342 | MpegEncContext *s = &v->s; |
| 343 | MPVPicture *f = &s->cur_pic; | 343 | MPVWorkPicture *f = &s->cur_pic; |
| 344 | int plane, i; | 344 | int plane, i; |
| 345 | 345 | ||
| 346 | /* Windows Media Image codecs have a convergence interval of two keyframes. | 346 | /* Windows Media Image codecs have a convergence interval of two keyframes. |
| @@ -837,10 +837,10 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 490 unmodified lines | |||
| 837 | /* no supplementary picture */ | 837 | /* no supplementary picture */ |
| 838 | if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) { | 838 | if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) { |
| 839 | /* special case for last picture */ | 839 | /* special case for last picture */ |
| 840 | if (s->low_delay == 0 && s->next_pic_ptr) { | 840 | if (s->low_delay == 0 && s->next_pic.ptr) { |
| 841 | if ((ret = av_frame_ref(pict, s->next_pic_ptr->f)) < 0) | 841 | if ((ret = av_frame_ref(pict, s->next_pic.ptr->f)) < 0) |
| 842 | return ret; | 842 | return ret; |
| 843 | s->next_pic_ptr = NULL; | 843 | s->next_pic.ptr = NULL; |
| 844 | 844 | ||
| 845 | *got_frame = 1; | 845 | *got_frame = 1; |
| 846 | } | 846 | } |
| @@ -1047,7 +1047,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 200 unmodified lines | |||
| 1047 | } | 1047 | } |
| 1048 | 1048 | ||
| 1049 | /* skip B-frames if we don't have reference frames */ | 1049 | /* skip B-frames if we don't have reference frames */ |
| 1050 | if (!s->last_pic_ptr && s->pict_type == AV_PICTURE_TYPE_B) { | 1050 | if (!s->last_pic.ptr && s->pict_type == AV_PICTURE_TYPE_B) { |
| 1051 | av_log(v->s.avctx, AV_LOG_DEBUG, "Skipping B frame without reference frames\n"); | 1051 | av_log(v->s.avctx, AV_LOG_DEBUG, "Skipping B frame without reference frames\n"); |
| 1052 | goto end; | 1052 | goto end; |
| 1053 | } | 1053 | } |
| @@ -1061,21 +1061,21 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 7 unmodified lines | |||
| 1061 | goto err; | 1061 | goto err; |
| 1062 | } | 1062 | } |
| 1063 | 1063 | ||
| 1064 | v->s.cur_pic_ptr->field_picture = v->field_mode; | 1064 | v->s.cur_pic.ptr->field_picture = v->field_mode; |
| 1065 | v->s.cur_pic_ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * (v->fcm != PROGRESSIVE); | 1065 | v->s.cur_pic.ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * (v->fcm != PROGRESSIVE); |
| 1066 | v->s.cur_pic_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!v->tff; | 1066 | v->s.cur_pic.ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!v->tff; |
| 1067 | v->last_interlaced = v->s.last_pic_ptr ? v->s.last_pic_ptr->f->flags & AV_FRAME_FLAG_INTERLACED : 0; | 1067 | v->last_interlaced = v->s.last_pic.ptr ? v->s.last_pic.ptr->f->flags & AV_FRAME_FLAG_INTERLACED : 0; |
| 1068 | v->next_interlaced = v->s.next_pic_ptr ? v->s.next_pic_ptr->f->flags & AV_FRAME_FLAG_INTERLACED : 0; | 1068 | v->next_interlaced = v->s.next_pic.ptr ? v->s.next_pic.ptr->f->flags & AV_FRAME_FLAG_INTERLACED : 0; |
| 1069 | 1069 | ||
| 1070 | // process pulldown flags | 1070 | // process pulldown flags |
| 1071 | s->cur_pic_ptr->f->repeat_pict = 0; | 1071 | s->cur_pic.ptr->f->repeat_pict = 0; |
| 1072 | // Pulldown flags are only valid when 'broadcast' has been set. | 1072 | // Pulldown flags are only valid when 'broadcast' has been set. |
| 1073 | if (v->rff) { | 1073 | if (v->rff) { |
| 1074 | // repeat field | 1074 | // repeat field |
| 1075 | s->cur_pic_ptr->f->repeat_pict = 1; | 1075 | s->cur_pic.ptr->f->repeat_pict = 1; |
| 1076 | } else if (v->rptfrm) { | 1076 | } else if (v->rptfrm) { |
| 1077 | // repeat frames | 1077 | // repeat frames |
| 1078 | s->cur_pic_ptr->f->repeat_pict = v->rptfrm * 2; | 1078 | s->cur_pic.ptr->f->repeat_pict = v->rptfrm * 2; |
| 1079 | } | 1079 | } |
| 1080 | 1080 | ||
| 1081 | if (avctx->hwaccel) { | 1081 | if (avctx->hwaccel) { |
| @@ -1137,7 +1137,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 55 unmodified lines | |||
| 1137 | ret = AVERROR_INVALIDDATA; | 1137 | ret = AVERROR_INVALIDDATA; |
| 1138 | goto err; | 1138 | goto err; |
| 1139 | } | 1139 | } |
| 1140 | v->s.cur_pic_ptr->f->pict_type = v->s.pict_type; | 1140 | v->s.cur_pic.ptr->f->pict_type = v->s.pict_type; |
| 1141 | 1141 | ||
| 1142 | ret = hwaccel->start_frame(avctx, buf_start_second_field, | 1142 | ret = hwaccel->start_frame(avctx, buf_start_second_field, |
| 1143 | (buf + buf_size) - buf_start_second_field); | 1143 | (buf + buf_size) - buf_start_second_field); |
| @@ -1355,16 +1355,16 @@ image: · 211 unmodified lines | |||
| 1355 | *got_frame = 1; | 1355 | *got_frame = 1; |
| 1356 | } else { | 1356 | } else { |
| 1357 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { | 1357 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { |
| 1358 | if ((ret = av_frame_ref(pict, s->cur_pic_ptr->f)) < 0) | 1358 | if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0) |
| 1359 | goto err; | 1359 | goto err; |
| 1360 | if (!v->field_mode) | 1360 | if (!v->field_mode) |
| 1361 | ff_print_debug_info(s, s->cur_pic_ptr, pict); | 1361 | ff_print_debug_info(s, s->cur_pic.ptr, pict); |
| 1362 | *got_frame = 1; | 1362 | *got_frame = 1; |
| 1363 | } else if (s->last_pic_ptr) { | 1363 | } else if (s->last_pic.ptr) { |
| 1364 | if ((ret = av_frame_ref(pict, s->last_pic_ptr->f)) < 0) | 1364 | if ((ret = av_frame_ref(pict, s->last_pic.ptr->f)) < 0) |
| 1365 | goto err; | 1365 | goto err; |
| 1366 | if (!v->field_mode) | 1366 | if (!v->field_mode) |
| 1367 | ff_print_debug_info(s, s->last_pic_ptr, pict); | 1367 | ff_print_debug_info(s, s->last_pic.ptr, pict); |
| 1368 | *got_frame = 1; | 1368 | *got_frame = 1; |
| 1369 | } | 1369 | } |
| 1370 | } | 1370 | } |
| @@ -370,7 +370,7 @@ int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame, · 369 unmodified lines | |||
| 370 | int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx) | 370 | int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx) |
| 371 | { | 371 | { |
| 372 | MpegEncContext *s = avctx->priv_data; | 372 | MpegEncContext *s = avctx->priv_data; |
| 373 | MPVPicture *pic = s->cur_pic_ptr; | 373 | MPVPicture *pic = s->cur_pic.ptr; |
| 374 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; | 374 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; |
| 375 | int val; | 375 | int val; |
| 376 | 376 | ||
| @@ -35,7 +35,7 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx, · 34 unmodified lines | |||
| 35 | const uint8_t *buffer, uint32_t size) | 35 | const uint8_t *buffer, uint32_t size) |
| 36 | { | 36 | { |
| 37 | MpegEncContext * const s = avctx->priv_data; | 37 | MpegEncContext * const s = avctx->priv_data; |
| 38 | MPVPicture *pic = s->cur_pic_ptr; | 38 | MPVPicture *pic = s->cur_pic.ptr; |
| 39 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; | 39 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; |
| 40 | VdpPictureInfoMPEG1Or2 *info = &pic_ctx->info.mpeg; | 40 | VdpPictureInfoMPEG1Or2 *info = &pic_ctx->info.mpeg; |
| 41 | VdpVideoSurface ref; | 41 | VdpVideoSurface ref; |
| @@ -47,12 +47,12 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx, · 5 unmodified lines | |||
| 47 | 47 | ||
| 48 | switch (s->pict_type) { | 48 | switch (s->pict_type) { |
| 49 | case AV_PICTURE_TYPE_B: | 49 | case AV_PICTURE_TYPE_B: |
| 50 | ref = ff_vdpau_get_surface_id(s->next_pic.f); | 50 | ref = ff_vdpau_get_surface_id(s->next_pic.ptr->f); |
| 51 | assert(ref != VDP_INVALID_HANDLE); | 51 | assert(ref != VDP_INVALID_HANDLE); |
| 52 | info->backward_reference = ref; | 52 | info->backward_reference = ref; |
| 53 | /* fall through to forward prediction */ | 53 | /* fall through to forward prediction */ |
| 54 | case AV_PICTURE_TYPE_P: | 54 | case AV_PICTURE_TYPE_P: |
| 55 | ref = ff_vdpau_get_surface_id(s->last_pic.f); | 55 | ref = ff_vdpau_get_surface_id(s->last_pic.ptr->f); |
| 56 | info->forward_reference = ref; | 56 | info->forward_reference = ref; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| @@ -87,7 +87,7 @@ static int vdpau_mpeg_decode_slice(AVCodecContext *avctx, · 28 unmodified lines | |||
| 87 | const uint8_t *buffer, uint32_t size) | 87 | const uint8_t *buffer, uint32_t size) |
| 88 | { | 88 | { |
| 89 | MpegEncContext * const s = avctx->priv_data; | 89 | MpegEncContext * const s = avctx->priv_data; |
| 90 | MPVPicture *pic = s->cur_pic_ptr; | 90 | MPVPicture *pic = s->cur_pic.ptr; |
| 91 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; | 91 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; |
| 92 | int val; | 92 | int val; |
| 93 | 93 | ||
| @@ -34,7 +34,7 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, · 33 unmodified lines | |||
| 34 | { | 34 | { |
| 35 | Mpeg4DecContext *ctx = avctx->priv_data; | 35 | Mpeg4DecContext *ctx = avctx->priv_data; |
| 36 | MpegEncContext * const s = &ctx->m; | 36 | MpegEncContext * const s = &ctx->m; |
| 37 | MPVPicture *pic = s->cur_pic_ptr; | 37 | MPVPicture *pic = s->cur_pic.ptr; |
| 38 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; | 38 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; |
| 39 | VdpPictureInfoMPEG4Part2 *info = &pic_ctx->info.mpeg4; | 39 | VdpPictureInfoMPEG4Part2 *info = &pic_ctx->info.mpeg4; |
| 40 | VdpVideoSurface ref; | 40 | VdpVideoSurface ref; |
| @@ -47,13 +47,13 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, · 6 unmodified lines | |||
| 47 | 47 | ||
| 48 | switch (s->pict_type) { | 48 | switch (s->pict_type) { |
| 49 | case AV_PICTURE_TYPE_B: | 49 | case AV_PICTURE_TYPE_B: |
| 50 | ref = ff_vdpau_get_surface_id(s->next_pic.f); | 50 | ref = ff_vdpau_get_surface_id(s->next_pic.ptr->f); |
| 51 | assert(ref != VDP_INVALID_HANDLE); | 51 | assert(ref != VDP_INVALID_HANDLE); |
| 52 | info->backward_reference = ref; | 52 | info->backward_reference = ref; |
| 53 | info->vop_coding_type = 2; | 53 | info->vop_coding_type = 2; |
| 54 | /* fall-through */ | 54 | /* fall-through */ |
| 55 | case AV_PICTURE_TYPE_P: | 55 | case AV_PICTURE_TYPE_P: |
| 56 | ref = ff_vdpau_get_surface_id(s->last_pic.f); | 56 | ref = ff_vdpau_get_surface_id(s->last_pic.ptr->f); |
| 57 | assert(ref != VDP_INVALID_HANDLE); | 57 | assert(ref != VDP_INVALID_HANDLE); |
| 58 | info->forward_reference = ref; | 58 | info->forward_reference = ref; |
| 59 | } | 59 | } |
| @@ -36,7 +36,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx, · 35 unmodified lines | |||
| 36 | { | 36 | { |
| 37 | VC1Context * const v = avctx->priv_data; | 37 | VC1Context * const v = avctx->priv_data; |
| 38 | MpegEncContext * const s = &v->s; | 38 | MpegEncContext * const s = &v->s; |
| 39 | MPVPicture *pic = s->cur_pic_ptr; | 39 | MPVPicture *pic = s->cur_pic.ptr; |
| 40 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; | 40 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; |
| 41 | VdpPictureInfoVC1 *info = &pic_ctx->info.vc1; | 41 | VdpPictureInfoVC1 *info = &pic_ctx->info.vc1; |
| 42 | VdpVideoSurface ref; | 42 | VdpVideoSurface ref; |
| @@ -47,15 +47,15 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx, · 4 unmodified lines | |||
| 47 | 47 | ||
| 48 | switch (s->pict_type) { | 48 | switch (s->pict_type) { |
| 49 | case AV_PICTURE_TYPE_B: | 49 | case AV_PICTURE_TYPE_B: |
| 50 | if (s->next_pic_ptr) { | 50 | if (s->next_pic.ptr) { |
| 51 | ref = ff_vdpau_get_surface_id(s->next_pic.f); | 51 | ref = ff_vdpau_get_surface_id(s->next_pic.ptr->f); |
| 52 | assert(ref != VDP_INVALID_HANDLE); | 52 | assert(ref != VDP_INVALID_HANDLE); |
| 53 | info->backward_reference = ref; | 53 | info->backward_reference = ref; |
| 54 | } | 54 | } |
| 55 | /* fall-through */ | 55 | /* fall-through */ |
| 56 | case AV_PICTURE_TYPE_P: | 56 | case AV_PICTURE_TYPE_P: |
| 57 | if (s->last_pic_ptr) { | 57 | if (s->last_pic.ptr) { |
| 58 | ref = ff_vdpau_get_surface_id(s->last_pic.f); | 58 | ref = ff_vdpau_get_surface_id(s->last_pic.ptr->f); |
| 59 | assert(ref != VDP_INVALID_HANDLE); | 59 | assert(ref != VDP_INVALID_HANDLE); |
| 60 | info->forward_reference = ref; | 60 | info->forward_reference = ref; |
| 61 | } | 61 | } |
| @@ -104,7 +104,7 @@ static int vdpau_vc1_decode_slice(AVCodecContext *avctx, · 42 unmodified lines | |||
| 104 | { | 104 | { |
| 105 | VC1Context * const v = avctx->priv_data; | 105 | VC1Context * const v = avctx->priv_data; |
| 106 | MpegEncContext * const s = &v->s; | 106 | MpegEncContext * const s = &v->s; |
| 107 | MPVPicture *pic = s->cur_pic_ptr; | 107 | MPVPicture *pic = s->cur_pic.ptr; |
| 108 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; | 108 | struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; |
| 109 | int val; | 109 | int val; |
| 110 | 110 | ||
| @@ -1108,7 +1108,7 @@ static int videotoolbox_mpeg_decode_slice(AVCodecContext *avctx, · 1107 unmodified lines | |||
| 1108 | static int videotoolbox_mpeg_end_frame(AVCodecContext *avctx) | 1108 | static int videotoolbox_mpeg_end_frame(AVCodecContext *avctx) |
| 1109 | { | 1109 | { |
| 1110 | MpegEncContext *s = avctx->priv_data; | 1110 | MpegEncContext *s = avctx->priv_data; |
| 1111 | AVFrame *frame = s->cur_pic_ptr->f; | 1111 | AVFrame *frame = s->cur_pic.ptr->f; |
| 1112 | 1112 | ||
| 1113 | return ff_videotoolbox_common_end_frame(avctx, frame); | 1113 | return ff_videotoolbox_common_end_frame(avctx, frame); |
| 1114 | } | 1114 | } |
| @@ -330,7 +330,7 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s) · 329 unmodified lines | |||
| 330 | s->esc3_run_length = 0; | 330 | s->esc3_run_length = 0; |
| 331 | 331 | ||
| 332 | if (w->j_type) { | 332 | if (w->j_type) { |
| 333 | ff_intrax8_decode_picture(&w->x8, &s->cur_pic, | 333 | ff_intrax8_decode_picture(&w->x8, s->cur_pic.ptr, |
| 334 | &s->gb, &s->mb_x, &s->mb_y, | 334 | &s->gb, &s->mb_x, &s->mb_y, |
| 335 | 2 * s->qscale, (s->qscale - 1) | 1, | 335 | 2 * s->qscale, (s->qscale - 1) | 1, |
| 336 | s->loop_filter, s->low_delay); | 336 | s->loop_filter, s->low_delay); |