You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

554 lines
22KB

  1. /*
  2. * DXVA2 H264 HW acceleration.
  3. *
  4. * copyright (c) 2009 Laurent Aimar
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include "dxva2.h"
  23. #include "avcodec.h"
  24. #include "mpegvideo.h"
  25. #include "h264.h"
  26. #include "h264data.h"
  27. struct dxva2_picture_context {
  28. DXVA_PicParams_H264 pp;
  29. DXVA_Qmatrix_H264 qm;
  30. unsigned slice_count;
  31. DXVA_Slice_H264_Short slice_short[MAX_SLICES];
  32. DXVA_Slice_H264_Long slice_long[MAX_SLICES];
  33. const uint8_t *bitstream;
  34. unsigned bitstream_size;
  35. };
  36. static void *get_surface(const Picture *picture)
  37. {
  38. return picture->data[3];
  39. }
  40. static unsigned get_surface_index(const struct dxva_context *ctx,
  41. const Picture *picture)
  42. {
  43. void *surface = get_surface(picture);
  44. unsigned i;
  45. for (i = 0; i < ctx->surface_count; i++)
  46. if (ctx->surface[i] == surface)
  47. return i;
  48. assert(0);
  49. return 0;
  50. }
  51. static void fill_picture_entry(DXVA_PicEntry_H264 *pic,
  52. unsigned index, unsigned flag)
  53. {
  54. assert((index&0x7f) == index && (flag&0x01) == flag);
  55. pic->bPicEntry = index | (flag << 7);
  56. }
  57. static void fill_picture_parameters(struct dxva_context *ctx, const H264Context *h,
  58. DXVA_PicParams_H264 *pp)
  59. {
  60. const MpegEncContext *s = &h->s;
  61. const Picture *current_picture = s->current_picture_ptr;
  62. int i;
  63. memset(pp, 0, sizeof(*pp));
  64. /* Configure current picture */
  65. fill_picture_entry(&pp->CurrPic,
  66. get_surface_index(ctx, current_picture),
  67. s->picture_structure == PICT_BOTTOM_FIELD);
  68. /* Configure the set of references */
  69. pp->UsedForReferenceFlags = 0;
  70. pp->NonExistingFrameFlags = 0;
  71. for (i = 0; i < FF_ARRAY_ELEMS(pp->RefFrameList); i++) {
  72. if (i < h->short_ref_count + h->long_ref_count) {
  73. const Picture *r;
  74. if (i < h->short_ref_count) {
  75. r = h->short_ref[i];
  76. assert(!r->long_ref);
  77. } else {
  78. r = h->long_ref[i - h->short_ref_count];
  79. assert(r->long_ref);
  80. }
  81. fill_picture_entry(&pp->RefFrameList[i],
  82. get_surface_index(ctx, r),
  83. r->long_ref != 0);
  84. if ((r->reference & PICT_TOP_FIELD) && r->field_poc[0] != INT_MAX)
  85. pp->FieldOrderCntList[i][0] = r->field_poc[0];
  86. if ((r->reference & PICT_BOTTOM_FIELD) && r->field_poc[1] != INT_MAX)
  87. pp->FieldOrderCntList[i][1] = r->field_poc[1];
  88. pp->FrameNumList[i] = r->long_ref ? r->pic_id : r->frame_num;
  89. if (r->reference & PICT_TOP_FIELD)
  90. pp->UsedForReferenceFlags |= 1 << (2*i + 0);
  91. if (r->reference & PICT_BOTTOM_FIELD)
  92. pp->UsedForReferenceFlags |= 1 << (2*i + 1);
  93. } else {
  94. pp->RefFrameList[i].bPicEntry = 0xff;
  95. pp->FieldOrderCntList[i][0] = 0;
  96. pp->FieldOrderCntList[i][1] = 0;
  97. pp->FrameNumList[i] = 0;
  98. }
  99. }
  100. pp->wFrameWidthInMbsMinus1 = s->mb_width - 1;
  101. pp->wFrameHeightInMbsMinus1 = s->mb_height - 1;
  102. pp->num_ref_frames = h->sps.ref_frame_count;
  103. pp->wBitFields = ((s->picture_structure != PICT_FRAME) << 0) |
  104. (h->sps.mb_aff << 1) |
  105. (h->sps.residual_color_transform_flag << 2) |
  106. /* sp_for_switch_flag (not implemented by FFmpeg) */
  107. (0 << 3) |
  108. (h->sps.chroma_format_idc << 4) |
  109. ((h->nal_ref_idc != 0) << 6) |
  110. (h->pps.constrained_intra_pred << 7) |
  111. (h->pps.weighted_pred << 8) |
  112. (h->pps.weighted_bipred_idc << 9) |
  113. /* MbsConsecutiveFlag */
  114. (1 << 11) |
  115. (h->sps.frame_mbs_only_flag << 12) |
  116. (h->pps.transform_8x8_mode << 13) |
  117. ((h->sps.level_idc >= 31) << 14) |
  118. /* IntraPicFlag (Modified if we detect a non
  119. * intra slice in decode_slice) */
  120. (1 << 15);
  121. pp->bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8;
  122. pp->bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8;
  123. pp->Reserved16Bits = 3; /* FIXME is there a way to detect the right mode ? */
  124. pp->StatusReportFeedbackNumber = 1 + ctx->report_id++;
  125. pp->CurrFieldOrderCnt[0] = 0;
  126. if ((s->picture_structure & PICT_TOP_FIELD) &&
  127. current_picture->field_poc[0] != INT_MAX)
  128. pp->CurrFieldOrderCnt[0] = current_picture->field_poc[0];
  129. pp->CurrFieldOrderCnt[1] = 0;
  130. if ((s->picture_structure & PICT_BOTTOM_FIELD) &&
  131. current_picture->field_poc[1] != INT_MAX)
  132. pp->CurrFieldOrderCnt[1] = current_picture->field_poc[1];
  133. pp->pic_init_qs_minus26 = h->pps.init_qs - 26;
  134. pp->chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0];
  135. pp->second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1];
  136. pp->ContinuationFlag = 1;
  137. pp->pic_init_qp_minus26 = h->pps.init_qp - 26;
  138. pp->num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1;
  139. pp->num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1;
  140. pp->Reserved8BitsA = 0;
  141. pp->frame_num = h->frame_num;
  142. pp->log2_max_frame_num_minus4 = h->sps.log2_max_frame_num - 4;
  143. pp->pic_order_cnt_type = h->sps.poc_type;
  144. if (h->sps.poc_type == 0)
  145. pp->log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4;
  146. else if (h->sps.poc_type == 1)
  147. pp->delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag;
  148. pp->direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag;
  149. pp->entropy_coding_mode_flag = h->pps.cabac;
  150. pp->pic_order_present_flag = h->pps.pic_order_present;
  151. pp->num_slice_groups_minus1 = h->pps.slice_group_count - 1;
  152. pp->slice_group_map_type = h->pps.mb_slice_group_map_type;
  153. pp->deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present;
  154. pp->redundant_pic_cnt_present_flag= h->pps.redundant_pic_cnt_present;
  155. pp->Reserved8BitsB = 0;
  156. pp->slice_group_change_rate_minus1= 0; /* XXX not implemented by FFmpeg */
  157. //pp->SliceGroupMap[810]; /* XXX not implemented by FFmpeg */
  158. }
  159. static void fill_scaling_lists(const H264Context *h, DXVA_Qmatrix_H264 *qm)
  160. {
  161. unsigned i, j;
  162. memset(qm, 0, sizeof(*qm));
  163. for (i = 0; i < 6; i++)
  164. for (j = 0; j < 16; j++)
  165. qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][zigzag_scan[j]];
  166. for (i = 0; i < 2; i++)
  167. for (j = 0; j < 64; j++)
  168. qm->bScalingLists8x8[i][j] = h->pps.scaling_matrix8[i][ff_zigzag_direct[j]];
  169. }
  170. static int is_slice_short(struct dxva_context *ctx)
  171. {
  172. assert(ctx->cfg->ConfigBitstreamRaw == 1 ||
  173. ctx->cfg->ConfigBitstreamRaw == 2);
  174. return ctx->cfg->ConfigBitstreamRaw == 2;
  175. }
  176. static void fill_slice_short(DXVA_Slice_H264_Short *slice,
  177. unsigned position, unsigned size)
  178. {
  179. memset(slice, 0, sizeof(*slice));
  180. slice->BSNALunitDataLocation = position;
  181. slice->SliceBytesInBuffer = size;
  182. slice->wBadSliceChopping = 0;
  183. }
  184. static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
  185. unsigned position, unsigned size)
  186. {
  187. H264Context *h = avctx->priv_data; /* FIXME Can't use const because of get_bits_count */
  188. struct dxva_context *ctx = avctx->hwaccel_context;
  189. MpegEncContext *s = &h->s;
  190. unsigned list;
  191. memset(slice, 0, sizeof(*slice));
  192. slice->BSNALunitDataLocation = position;
  193. slice->SliceBytesInBuffer = size;
  194. slice->wBadSliceChopping = 0;
  195. slice->first_mb_in_slice = (s->mb_y >> FIELD_OR_MBAFF_PICTURE) * s->mb_width + s->mb_x;
  196. slice->NumMbsForSlice = 0; /* XXX it is set once we have all slices */
  197. slice->BitOffsetToSliceData = get_bits_count(&s->gb) + 8;
  198. slice->slice_type = ff_h264_get_slice_type(h);
  199. if (h->slice_type_fixed)
  200. slice->slice_type += 5;
  201. slice->luma_log2_weight_denom = h->luma_log2_weight_denom;
  202. slice->chroma_log2_weight_denom = h->chroma_log2_weight_denom;
  203. if (h->list_count > 0)
  204. slice->num_ref_idx_l0_active_minus1 = h->ref_count[0] - 1;
  205. if (h->list_count > 1)
  206. slice->num_ref_idx_l1_active_minus1 = h->ref_count[1] - 1;
  207. slice->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
  208. slice->slice_beta_offset_div2 = h->slice_beta_offset / 2;
  209. slice->Reserved8Bits = 0;
  210. for (list = 0; list < 2; list++) {
  211. unsigned i;
  212. for (i = 0; i < FF_ARRAY_ELEMS(slice->RefPicList[list]); i++) {
  213. if (list < h->list_count && i < h->ref_count[list]) {
  214. const Picture *r = &h->ref_list[list][i];
  215. unsigned plane;
  216. fill_picture_entry(&slice->RefPicList[list][i],
  217. get_surface_index(ctx, r),
  218. r->reference == PICT_BOTTOM_FIELD);
  219. for (plane = 0; plane < 3; plane++) {
  220. int w, o;
  221. if (plane == 0 && h->luma_weight_flag[list]) {
  222. w = h->luma_weight[list][i];
  223. o = h->luma_offset[list][i];
  224. } else if (plane >= 1 && h->chroma_weight_flag[list]) {
  225. w = h->chroma_weight[list][i][plane-1];
  226. o = h->chroma_offset[list][i][plane-1];
  227. } else {
  228. w = 1 << (plane == 0 ? h->luma_log2_weight_denom :
  229. h->chroma_log2_weight_denom);
  230. o = 0;
  231. }
  232. slice->Weights[list][i][plane][0] = w;
  233. slice->Weights[list][i][plane][1] = o;
  234. }
  235. } else {
  236. unsigned plane;
  237. slice->RefPicList[list][i].bPicEntry = 0xff;
  238. for (plane = 0; plane < 3; plane++) {
  239. slice->Weights[list][i][plane][0] = 0;
  240. slice->Weights[list][i][plane][1] = 0;
  241. }
  242. }
  243. }
  244. }
  245. slice->slice_qs_delta = 0; /* XXX not implemented by FFmpeg */
  246. slice->slice_qp_delta = s->qscale - h->pps.init_qp;
  247. slice->redundant_pic_cnt = h->redundant_pic_count;
  248. if (h->slice_type == FF_B_TYPE)
  249. slice->direct_spatial_mv_pred_flag = h->direct_spatial_mv_pred;
  250. slice->cabac_init_idc = h->pps.cabac ? h->cabac_init_idc : 0;
  251. if (h->deblocking_filter < 2)
  252. slice->disable_deblocking_filter_idc = 1 - h->deblocking_filter;
  253. else
  254. slice->disable_deblocking_filter_idc = h->deblocking_filter;
  255. slice->slice_id = h->current_slice - 1;
  256. }
  257. static int commit_buffer(AVCodecContext *avctx,
  258. struct dxva_context *ctx,
  259. DXVA2_DecodeBufferDesc *dsc,
  260. unsigned type, const void *data, unsigned size,
  261. unsigned mb_count)
  262. {
  263. void *dxva_data;
  264. unsigned dxva_size;
  265. int result;
  266. if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->decoder, type,
  267. &dxva_data, &dxva_size))) {
  268. av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %d\n", type);
  269. return -1;
  270. }
  271. if (size <= dxva_size) {
  272. memcpy(dxva_data, data, size);
  273. memset(dsc, 0, sizeof(*dsc));
  274. dsc->CompressedBufferType = type;
  275. dsc->DataSize = size;
  276. dsc->NumMBsInBuffer = mb_count;
  277. result = 0;
  278. } else {
  279. av_log(avctx, AV_LOG_ERROR, "Buffer for type %d was too small\n", type);
  280. result = -1;
  281. }
  282. if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(ctx->decoder, type))) {
  283. av_log(avctx, AV_LOG_ERROR, "Failed to release buffer type %d\n", type);
  284. result = -1;
  285. }
  286. return result;
  287. }
  288. static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
  289. struct dxva_context *ctx,
  290. struct dxva2_picture_context *ctx_pic,
  291. DXVA2_DecodeBufferDesc *bs,
  292. DXVA2_DecodeBufferDesc *sc,
  293. unsigned mb_count)
  294. {
  295. DXVA_Slice_H264_Short *slice = NULL;
  296. uint8_t *dxva_data, *current, *end;
  297. unsigned dxva_size;
  298. void *slice_data;
  299. unsigned slice_size;
  300. unsigned padding;
  301. unsigned i;
  302. /* Create an annex B bitstream buffer with only slice NAL and finalize slice */
  303. if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->decoder,
  304. DXVA2_BitStreamDateBufferType,
  305. &dxva_data, &dxva_size)))
  306. return -1;
  307. current = dxva_data;
  308. end = dxva_data + dxva_size;
  309. for (i = 0; i < ctx_pic->slice_count; i++) {
  310. static const uint8_t start_code[] = { 0, 0, 1 };
  311. static const unsigned start_code_size = sizeof(start_code);
  312. unsigned position, size;
  313. assert(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==
  314. offsetof(DXVA_Slice_H264_Long, BSNALunitDataLocation));
  315. assert(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==
  316. offsetof(DXVA_Slice_H264_Long, SliceBytesInBuffer));
  317. if (is_slice_short(ctx))
  318. slice = &ctx_pic->slice_short[i];
  319. else
  320. slice = (DXVA_Slice_H264_Short*)&ctx_pic->slice_long[i];
  321. position = slice->BSNALunitDataLocation;
  322. size = slice->SliceBytesInBuffer;
  323. if (start_code_size + size > end - current) {
  324. av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream");
  325. break;
  326. }
  327. slice->BSNALunitDataLocation = current - dxva_data;
  328. slice->SliceBytesInBuffer = start_code_size + size;
  329. if (!is_slice_short(ctx)) {
  330. DXVA_Slice_H264_Long *slice_long = (DXVA_Slice_H264_Long*)slice;
  331. if (i < ctx_pic->slice_count - 1)
  332. slice_long->NumMbsForSlice =
  333. slice_long[1].first_mb_in_slice - slice_long[0].first_mb_in_slice;
  334. else
  335. slice_long->NumMbsForSlice = mb_count - slice_long->first_mb_in_slice;
  336. }
  337. memcpy(current, start_code, start_code_size);
  338. current += start_code_size;
  339. memcpy(current, &ctx_pic->bitstream[position], size);
  340. current += size;
  341. }
  342. padding = FFMIN(128 - ((current - dxva_data) & 127), end - current);
  343. if (slice && padding > 0) {
  344. memset(current, 0, padding);
  345. current += padding;
  346. slice->SliceBytesInBuffer += padding;
  347. }
  348. if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(ctx->decoder,
  349. DXVA2_BitStreamDateBufferType)))
  350. return -1;
  351. if (i < ctx_pic->slice_count)
  352. return -1;
  353. memset(bs, 0, sizeof(*bs));
  354. bs->CompressedBufferType = DXVA2_BitStreamDateBufferType;
  355. bs->DataSize = current - dxva_data;
  356. bs->NumMBsInBuffer = mb_count;
  357. if (is_slice_short(ctx)) {
  358. slice_data = ctx_pic->slice_short;
  359. slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_short);
  360. } else {
  361. slice_data = ctx_pic->slice_long;
  362. slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_long);
  363. }
  364. assert((bs->DataSize & 127) == 0);
  365. return commit_buffer(avctx, ctx, sc,
  366. DXVA2_SliceControlBufferType,
  367. slice_data, slice_size, mb_count);
  368. }
  369. static int start_frame(AVCodecContext *avctx,
  370. av_unused const uint8_t *buffer,
  371. av_unused uint32_t size)
  372. {
  373. const H264Context *h = avctx->priv_data;
  374. struct dxva_context *ctx = avctx->hwaccel_context;
  375. struct dxva2_picture_context *ctx_pic = h->s.current_picture_ptr->hwaccel_picture_private;
  376. if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0)
  377. return -1;
  378. assert(ctx_pic);
  379. /* Fill up DXVA_PicParams_H264 */
  380. fill_picture_parameters(ctx, h, &ctx_pic->pp);
  381. /* Fill up DXVA_Qmatrix_H264 */
  382. fill_scaling_lists(h, &ctx_pic->qm);
  383. ctx_pic->slice_count = 0;
  384. ctx_pic->bitstream_size = 0;
  385. ctx_pic->bitstream = NULL;
  386. return 0;
  387. }
  388. static int decode_slice(AVCodecContext *avctx,
  389. const uint8_t *buffer, uint32_t size)
  390. {
  391. H264Context *h = avctx->priv_data; /* FIXME Can't use const because of get_bits_count */
  392. struct dxva_context *ctx = avctx->hwaccel_context;
  393. const Picture *current_picture = h->s.current_picture_ptr;
  394. struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
  395. unsigned position;
  396. if (ctx_pic->slice_count >= MAX_SLICES)
  397. return -1;
  398. if (!ctx_pic->bitstream)
  399. ctx_pic->bitstream = buffer;
  400. ctx_pic->bitstream_size += size;
  401. position = buffer - ctx_pic->bitstream;
  402. if (is_slice_short(ctx))
  403. fill_slice_short(&ctx_pic->slice_short[ctx_pic->slice_count],
  404. position, size);
  405. else
  406. fill_slice_long(avctx, &ctx_pic->slice_long[ctx_pic->slice_count],
  407. position, size);
  408. ctx_pic->slice_count++;
  409. if (h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE)
  410. ctx_pic->pp.wBitFields &= ~(1 << 15); /* Set IntraPicFlag to 0 */
  411. return 0;
  412. }
  413. static int end_frame(AVCodecContext *avctx)
  414. {
  415. H264Context *h = avctx->priv_data;
  416. MpegEncContext *s = &h->s;
  417. const unsigned mb_count = s->mb_width * s->mb_height;
  418. struct dxva_context *ctx = avctx->hwaccel_context;
  419. const Picture *current_picture = h->s.current_picture_ptr;
  420. struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
  421. unsigned buffer_count = 0;
  422. DXVA2_DecodeBufferDesc buffer[4];
  423. DXVA2_DecodeExecuteParams exec;
  424. int result;
  425. if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
  426. return -1;
  427. if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder,
  428. get_surface(current_picture),
  429. NULL))) {
  430. av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n");
  431. return -1;
  432. }
  433. result = commit_buffer(avctx, ctx, &buffer[buffer_count],
  434. DXVA2_PictureParametersBufferType,
  435. &ctx_pic->pp, sizeof(ctx_pic->pp), 0);
  436. if (result) {
  437. av_log(avctx, AV_LOG_ERROR,
  438. "Failed to add picture parameter buffer\n");
  439. goto end;
  440. }
  441. buffer_count++;
  442. result = commit_buffer(avctx, ctx, &buffer[buffer_count],
  443. DXVA2_InverseQuantizationMatrixBufferType,
  444. &ctx_pic->qm, sizeof(ctx_pic->qm), 0);
  445. if (result) {
  446. av_log(avctx, AV_LOG_ERROR,
  447. "Failed to add inverse quantization matrix buffer\n");
  448. goto end;
  449. }
  450. buffer_count++;
  451. result = commit_bitstream_and_slice_buffer(avctx, ctx, ctx_pic,
  452. &buffer[buffer_count + 0],
  453. &buffer[buffer_count + 1],
  454. mb_count);
  455. if (result) {
  456. av_log(avctx, AV_LOG_ERROR,
  457. "Failed to add bitstream or slice control buffer\n");
  458. goto end;
  459. }
  460. buffer_count += 2;
  461. /* TODO Film Grain when possible */
  462. assert(buffer_count == 4);
  463. memset(&exec, 0, sizeof(exec));
  464. exec.NumCompBuffers = buffer_count;
  465. exec.pCompressedBuffers = buffer;
  466. exec.pExtensionData = NULL;
  467. if (FAILED(IDirectXVideoDecoder_Execute(ctx->decoder, &exec))) {
  468. av_log(avctx, AV_LOG_ERROR, "Failed to execute\n");
  469. result = -1;
  470. }
  471. end:
  472. if (FAILED(IDirectXVideoDecoder_EndFrame(ctx->decoder, NULL))) {
  473. av_log(avctx, AV_LOG_ERROR, "Failed to end frame\n");
  474. result = -1;
  475. }
  476. if (!result)
  477. ff_draw_horiz_band(s, 0, s->avctx->height);
  478. return result;
  479. }
  480. AVHWAccel h264_dxva2_hwaccel = {
  481. .name = "h264_dxva2",
  482. .type = CODEC_TYPE_VIDEO,
  483. .id = CODEC_ID_H264,
  484. .pix_fmt = PIX_FMT_DXVA2_VLD,
  485. .capabilities = 0,
  486. .start_frame = start_frame,
  487. .decode_slice = decode_slice,
  488. .end_frame = end_frame,
  489. .priv_data_size = sizeof(struct dxva2_picture_context),
  490. };