1 /***************************************************************************
2                           \fn     libvaEnc_plugin
3                           \brief  Plugin to use libva hw encoder (intel mostly)
4                              -------------------
5 
6     copyright            : (C) 2018 by mean
7     email                : fixounet@free.fr
8  ***************************************************************************/
9 
10 /***************************************************************************
11  *                                                                         *
12  *   This program is free software; you can redistribute it and/or modify  *
13  *   it under the terms of the GNU General Public License as published by  *
14  *   the Free Software Foundation; either version 2 of the License, or     *
15  *   (at your option) any later version.                                   *
16  *                                                                         *
17  ***************************************************************************/
18 #include "ADM_default.h"
19 #include "ADM_libvaEncoder.h"
20 #include "ADM_coreVideoEncoderInternal.h"
21 #include "DIA_factory.h"
22 #include "ADM_coreLibVA_h264Encoding.h"
23 
24 #include "vaenc_settings.h"
25 extern "C"
26 {
27 #include "vaenc_settings_desc.cpp"
28 }
29 extern bool     vaEncConfigure(void);
30  static const  vaconf_settings defaultConf = {10*1000,100};
31 vaconf_settings vaH264Settings=defaultConf;
32 /**
33  *
34  */
resetConfigurationData()35 void resetConfigurationData()
36 {
37     memcpy(&vaH264Settings, &defaultConf, sizeof(vaH264Settings));
38 }
39 
40 /**
41  *
42  * @return
43  */
ADM_libvaEncoder_probe()44 static bool         ADM_libvaEncoder_probe()
45 {
46     VAProfile profile=vaGetH264EncoderProfile()->profile;
47     if(profile==VAProfileNone)
48     {
49         ADM_error("No H264 encoding support\n");
50         return false;
51     }
52     return true;
53 }
54 ADM_DECLARE_VIDEO_ENCODER_PREAMBLE(ADM_libvaEncoder);
55 ADM_DECLARE_VIDEO_ENCODER_MAIN_EX("LibVaEncoder (HW)",
56                                "Intel AVC HW (VA)",
57                                "Simple Libva Encoder (c) 2018 Mean",
58                                 vaEncConfigure, // No configuration
59                                 ADM_UI_ALL,
60                                 1,0,0,
61                                 vaconf_settings_param, // conf template
62                                 &vaH264Settings, // conf var
63                                 NULL,NULL ,       // setProfile,getProfile)
64                                 ADM_libvaEncoder_probe
65 );
66 /**
67  *
68  * @return
69  */
vaEncConfigure(void)70 bool vaEncConfigure(void)
71 {
72 
73     diaElemUInteger  period(&(vaH264Settings.IntraPeriod),QT_TRANSLATE_NOOP("vaH264","_IDR Period:"),1,1000);
74     diaElemUInteger  bitrate(&(vaH264Settings.BitrateKbps),QT_TRANSLATE_NOOP("vaH264","_Bitrate(kbps)"),1,100*1000);
75 
76     diaElem *elems[2]={&bitrate,&period};
77     return diaFactoryRun(QT_TRANSLATE_NOOP("vaEncH264","vaH264 Configuration"),2 ,elems);
78 }
79 // EOF