Mercurial > libavcodec.hg
comparison dxva2_h264.c @ 10976:b3e3f5cb4b46 libavcodec
Added ff_dxva2_ prefix to get_surface(_index) and commit_buffer functions.
author | fenrir |
---|---|
date | Sat, 23 Jan 2010 18:01:28 +0000 |
parents | cec4a174365c |
children | 776dba50775c |
comparison
equal
deleted
inserted
replaced
10975:cec4a174365c | 10976:b3e3f5cb4b46 |
---|---|
35 DXVA_Slice_H264_Long slice_long[MAX_SLICES]; | 35 DXVA_Slice_H264_Long slice_long[MAX_SLICES]; |
36 const uint8_t *bitstream; | 36 const uint8_t *bitstream; |
37 unsigned bitstream_size; | 37 unsigned bitstream_size; |
38 }; | 38 }; |
39 | 39 |
40 static void *get_surface(const Picture *picture) | 40 static void *ff_dxva2_get_surface(const Picture *picture) |
41 { | 41 { |
42 return picture->data[3]; | 42 return picture->data[3]; |
43 } | 43 } |
44 static unsigned get_surface_index(const struct dxva_context *ctx, | 44 static unsigned ff_dxva2_get_surface_index(const struct dxva_context *ctx, |
45 const Picture *picture) | 45 const Picture *picture) |
46 { | 46 { |
47 void *surface = get_surface(picture); | 47 void *surface = ff_dxva2_get_surface(picture); |
48 unsigned i; | 48 unsigned i; |
49 | 49 |
50 for (i = 0; i < ctx->surface_count; i++) | 50 for (i = 0; i < ctx->surface_count; i++) |
51 if (ctx->surface[i] == surface) | 51 if (ctx->surface[i] == surface) |
52 return i; | 52 return i; |
70 int i; | 70 int i; |
71 | 71 |
72 memset(pp, 0, sizeof(*pp)); | 72 memset(pp, 0, sizeof(*pp)); |
73 /* Configure current picture */ | 73 /* Configure current picture */ |
74 fill_picture_entry(&pp->CurrPic, | 74 fill_picture_entry(&pp->CurrPic, |
75 get_surface_index(ctx, current_picture), | 75 ff_dxva2_get_surface_index(ctx, current_picture), |
76 s->picture_structure == PICT_BOTTOM_FIELD); | 76 s->picture_structure == PICT_BOTTOM_FIELD); |
77 /* Configure the set of references */ | 77 /* Configure the set of references */ |
78 pp->UsedForReferenceFlags = 0; | 78 pp->UsedForReferenceFlags = 0; |
79 pp->NonExistingFrameFlags = 0; | 79 pp->NonExistingFrameFlags = 0; |
80 for (i = 0; i < FF_ARRAY_ELEMS(pp->RefFrameList); i++) { | 80 for (i = 0; i < FF_ARRAY_ELEMS(pp->RefFrameList); i++) { |
86 } else { | 86 } else { |
87 r = h->long_ref[i - h->short_ref_count]; | 87 r = h->long_ref[i - h->short_ref_count]; |
88 assert(r->long_ref); | 88 assert(r->long_ref); |
89 } | 89 } |
90 fill_picture_entry(&pp->RefFrameList[i], | 90 fill_picture_entry(&pp->RefFrameList[i], |
91 get_surface_index(ctx, r), | 91 ff_dxva2_get_surface_index(ctx, r), |
92 r->long_ref != 0); | 92 r->long_ref != 0); |
93 | 93 |
94 if ((r->reference & PICT_TOP_FIELD) && r->field_poc[0] != INT_MAX) | 94 if ((r->reference & PICT_TOP_FIELD) && r->field_poc[0] != INT_MAX) |
95 pp->FieldOrderCntList[i][0] = r->field_poc[0]; | 95 pp->FieldOrderCntList[i][0] = r->field_poc[0]; |
96 if ((r->reference & PICT_BOTTOM_FIELD) && r->field_poc[1] != INT_MAX) | 96 if ((r->reference & PICT_BOTTOM_FIELD) && r->field_poc[1] != INT_MAX) |
234 for (i = 0; i < FF_ARRAY_ELEMS(slice->RefPicList[list]); i++) { | 234 for (i = 0; i < FF_ARRAY_ELEMS(slice->RefPicList[list]); i++) { |
235 if (list < h->list_count && i < h->ref_count[list]) { | 235 if (list < h->list_count && i < h->ref_count[list]) { |
236 const Picture *r = &h->ref_list[list][i]; | 236 const Picture *r = &h->ref_list[list][i]; |
237 unsigned plane; | 237 unsigned plane; |
238 fill_picture_entry(&slice->RefPicList[list][i], | 238 fill_picture_entry(&slice->RefPicList[list][i], |
239 get_surface_index(ctx, r), | 239 ff_dxva2_get_surface_index(ctx, r), |
240 r->reference == PICT_BOTTOM_FIELD); | 240 r->reference == PICT_BOTTOM_FIELD); |
241 for (plane = 0; plane < 3; plane++) { | 241 for (plane = 0; plane < 3; plane++) { |
242 int w, o; | 242 int w, o; |
243 if (plane == 0 && h->luma_weight_flag[list]) { | 243 if (plane == 0 && h->luma_weight_flag[list]) { |
244 w = h->luma_weight[list][i]; | 244 w = h->luma_weight[list][i]; |
275 else | 275 else |
276 slice->disable_deblocking_filter_idc = h->deblocking_filter; | 276 slice->disable_deblocking_filter_idc = h->deblocking_filter; |
277 slice->slice_id = h->current_slice - 1; | 277 slice->slice_id = h->current_slice - 1; |
278 } | 278 } |
279 | 279 |
280 static int commit_buffer(AVCodecContext *avctx, | 280 static int ff_dxva2_commit_buffer(AVCodecContext *avctx, |
281 struct dxva_context *ctx, | 281 struct dxva_context *ctx, |
282 DXVA2_DecodeBufferDesc *dsc, | 282 DXVA2_DecodeBufferDesc *dsc, |
283 unsigned type, const void *data, unsigned size, | 283 unsigned type, const void *data, unsigned size, |
284 unsigned mb_count) | 284 unsigned mb_count) |
285 { | 285 { |
286 void *dxva_data; | 286 void *dxva_data; |
287 unsigned dxva_size; | 287 unsigned dxva_size; |
288 int result; | 288 int result; |
289 | 289 |
402 } else { | 402 } else { |
403 slice_data = ctx_pic->slice_long; | 403 slice_data = ctx_pic->slice_long; |
404 slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_long); | 404 slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_long); |
405 } | 405 } |
406 assert((bs->DataSize & 127) == 0); | 406 assert((bs->DataSize & 127) == 0); |
407 return commit_buffer(avctx, ctx, sc, | 407 return ff_dxva2_commit_buffer(avctx, ctx, sc, |
408 DXVA2_SliceControlBufferType, | 408 DXVA2_SliceControlBufferType, |
409 slice_data, slice_size, mb_count); | 409 slice_data, slice_size, mb_count); |
410 } | 410 } |
411 | 411 |
412 | 412 |
413 static int start_frame(AVCodecContext *avctx, | 413 static int start_frame(AVCodecContext *avctx, |
414 av_unused const uint8_t *buffer, | 414 av_unused const uint8_t *buffer, |
476 DXVA2_DecodeBufferDesc buffer[4]; | 476 DXVA2_DecodeBufferDesc buffer[4]; |
477 DXVA2_DecodeExecuteParams exec; | 477 DXVA2_DecodeExecuteParams exec; |
478 int result; | 478 int result; |
479 | 479 |
480 if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder, | 480 if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder, |
481 get_surface(s->current_picture_ptr), | 481 ff_dxva2_get_surface(s->current_picture_ptr), |
482 NULL))) { | 482 NULL))) { |
483 av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n"); | 483 av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n"); |
484 return -1; | 484 return -1; |
485 } | 485 } |
486 | 486 |
487 result = commit_buffer(avctx, ctx, &buffer[buffer_count], | 487 result = ff_dxva2_commit_buffer(avctx, ctx, &buffer[buffer_count], |
488 DXVA2_PictureParametersBufferType, | 488 DXVA2_PictureParametersBufferType, |
489 pp, pp_size, 0); | 489 pp, pp_size, 0); |
490 if (result) { | 490 if (result) { |
491 av_log(avctx, AV_LOG_ERROR, | 491 av_log(avctx, AV_LOG_ERROR, |
492 "Failed to add picture parameter buffer\n"); | 492 "Failed to add picture parameter buffer\n"); |
493 goto end; | 493 goto end; |
494 } | 494 } |
495 buffer_count++; | 495 buffer_count++; |
496 | 496 |
497 if (qm_size > 0) { | 497 if (qm_size > 0) { |
498 result = commit_buffer(avctx, ctx, &buffer[buffer_count], | 498 result = ff_dxva2_commit_buffer(avctx, ctx, &buffer[buffer_count], |
499 DXVA2_InverseQuantizationMatrixBufferType, | 499 DXVA2_InverseQuantizationMatrixBufferType, |
500 qm, qm_size, 0); | 500 qm, qm_size, 0); |
501 if (result) { | 501 if (result) { |
502 av_log(avctx, AV_LOG_ERROR, | 502 av_log(avctx, AV_LOG_ERROR, |
503 "Failed to add inverse quantization matrix buffer\n"); | 503 "Failed to add inverse quantization matrix buffer\n"); |
504 goto end; | 504 goto end; |
505 } | 505 } |