Debian Codegraph @

doc/spec/source/snippets/prg_transcoding.c

raw
1 /*############################################################################
2 # Copyright (C) 2020 Intel Corporation
3 #
4 # SPDX-License-Identifier: MIT
5 ############################################################################*/
6
7 #include <stdlib.h>
8
9 #include "mfxdefs.h"
10 #include "mfxstructures.h"
11 #include "mfxsession.h"
12 #include "mfxvideo.h"
13
14 /* These macro required for code compilation. */
15 #define INFINITE 0
16 #define UNUSED_PARAM(x) (void)(x)
17
18 mfxSession session;
19 mfxBitstream *bs, *bits2;
20 mfxFrameSurface1 *work, *vin, *vout;
21 int going_through_vpp=1;
22
23 static void allocate_surfaces(mfxU32 num_surfaces) {
24 UNUSED_PARAM(num_surfaces);
25 }
26
27 /* end of internal stuff */
28
29 static void prg_transcoding1 () {
30 /*beg1*/
31 mfxSyncPoint sp_d, sp_e;
32 MFXVideoDECODE_DecodeFrameAsync(session,bs,work,&vin, &sp_d);
33 if (going_through_vpp) {
34 MFXVideoVPP_RunFrameVPPAsync(session,vin,vout, NULL, &sp_d);
35 MFXVideoENCODE_EncodeFrameAsync(session,NULL,vout,bits2,&sp_e);
36 } else {
37 MFXVideoENCODE_EncodeFrameAsync(session,NULL,vin,bits2,&sp_e);
38 }
39 MFXVideoCORE_SyncOperation(session,sp_e,INFINITE);
40 /*end1*/
41 }
42
43 static void prg_transcoding2 () {
44 /*beg2*/
45 mfxVideoParam init_param_v, init_param_e;
46 mfxFrameAllocRequest response_v[2], response_e;
47
48 // Desired depth
49 mfxU16 async_depth=4;
50
51 init_param_v.AsyncDepth=async_depth;
52 MFXVideoVPP_QueryIOSurf(session, &init_param_v, response_v);
53 init_param_e.AsyncDepth=async_depth;
54 MFXVideoENCODE_QueryIOSurf(session, &init_param_e, &response_e);
55 mfxU32 num_surfaces = response_v[1].NumFrameSuggested
56 + response_e.NumFrameSuggested
57 - async_depth; /* double counted in ENCODE & VPP */
58
59 allocate_surfaces(num_surfaces);
60 /*end2*/
61 }