1/******************************************************************************
2 *
3 * Copyright (C) 2015 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *****************************************************************************
18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19*/
20/*****************************************************************************/
21/*                                                                           */
22/*  File Name         : ih264e.h                                    */
23/*                                                                           */
24/*  Description       : This file contains all the necessary structure and   */
25/*                      enumeration definitions needed for the Application   */
26/*                      Program Interface(API) of the Ittiam MPEG4        */
27/*                      Encoder on Cortex A8 - Neon platform                 */
28/*                                                                           */
29/*  List of Functions : ih264e_api_function                              */
30/*                                                                           */
31/*  Issues / Problems : None                                                 */
32/*                                                                           */
33/*  Revision History  :                                                      */
34/*                                                                           */
35/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
36/*         26 08 2010   100239(RCY)     Draft                                */
37/*                                                                           */
38/*****************************************************************************/
39
40#ifndef _IH264E_H_
41#define _IH264E_H_
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47#include "iv2.h"
48#include "ive2.h"
49/*****************************************************************************/
50/* Constant Macros                                                           */
51/*****************************************************************************/
52
53
54/*****************************************************************************/
55/* API Function Prototype                                                    */
56/*****************************************************************************/
57IV_STATUS_T ih264e_api_function(iv_obj_t *ps_handle, void *pv_api_ip,void *pv_api_op);
58
59/*****************************************************************************/
60/* Enums                                                                     */
61/*****************************************************************************/
62typedef enum
63{
64    IH264E_CMD_CTL_SET_ME_INFO_ENABLE,
65}IH264E_CMD_CTL_SUB_CMDS;
66
67
68/*****************************************************************************/
69/* Extended Structures                                                       */
70/*****************************************************************************/
71
72/*****************************************************************************/
73/*  Get Number of Memory Records                                             */
74/*****************************************************************************/
75
76
77typedef struct
78{
79    iv_num_mem_rec_ip_t                    s_ive_ip;
80}ih264e_num_mem_rec_ip_t;
81
82
83typedef struct
84{
85    iv_num_mem_rec_op_t                    s_ive_op;
86}ih264e_num_mem_rec_op_t;
87
88
89/*****************************************************************************/
90/*  Fill Memory Records                                                      */
91/*****************************************************************************/
92
93
94typedef struct
95{
96    iv_fill_mem_rec_ip_t                   s_ive_ip;
97}ih264e_fill_mem_rec_ip_t;
98
99
100typedef struct
101{
102    iv_fill_mem_rec_op_t                   s_ive_op;
103}ih264e_fill_mem_rec_op_t;
104
105/*****************************************************************************/
106/*  Retrieve Memory Records                                                  */
107/*****************************************************************************/
108
109
110typedef struct
111{
112    iv_retrieve_mem_rec_ip_t               s_ive_ip;
113}ih264e_retrieve_mem_rec_ip_t;
114
115
116typedef struct
117{
118    iv_retrieve_mem_rec_op_t               s_ive_op;
119}ih264e_retrieve_mem_rec_op_t;
120
121
122/*****************************************************************************/
123/*   Initialize encoder                                                      */
124/*****************************************************************************/
125
126typedef struct
127{
128    ive_init_ip_t                           s_ive_ip;
129}ih264e_init_ip_t;
130
131
132typedef struct
133{
134    ive_init_op_t                           s_ive_op;
135}ih264e_init_op_t;
136
137
138/*****************************************************************************/
139/*   Queue Input raw buffer - Send the YUV buffer to be encoded              */
140/*****************************************************************************/
141typedef struct
142{
143    ive_queue_inp_ip_t                      s_ive_ip;
144}ih264e_queue_inp_ip_t;
145
146typedef struct
147{
148    ive_queue_inp_op_t                      s_ive_op;
149}ih264e_queue_inp_op_t;
150
151/*****************************************************************************/
152/*   Dequeue Input raw buffer - Get free YUV buffer from the encoder         */
153/*****************************************************************************/
154typedef struct
155{
156    ive_dequeue_inp_ip_t                      s_ive_ip;
157}ih264e_dequeue_inp_ip_t;
158
159typedef struct
160{
161    ive_dequeue_inp_op_t                      s_ive_op;
162}ih264e_dequeue_inp_op_t;
163
164
165/*****************************************************************************/
166/*   Queue Output bitstream buffer - Send the bistream buffer to be filled   */
167/*****************************************************************************/
168typedef struct
169{
170    ive_queue_out_ip_t                      s_ive_ip;
171}ih264e_queue_out_ip_t;
172
173typedef struct
174{
175    ive_queue_out_op_t                      s_ive_op;
176}ih264e_queue_out_op_t;
177
178/*****************************************************************************/
179/* Dequeue Output bitstream buffer - Get the bistream buffer filled          */
180/*****************************************************************************/
181typedef struct
182{
183    ive_dequeue_out_ip_t                      s_ive_ip;
184}ih264e_dequeue_out_ip_t;
185
186typedef struct
187{
188    ive_dequeue_out_op_t                      s_ive_op;
189}ih264e_dequeue_out_op_t;
190
191
192/*****************************************************************************/
193/* Get Recon data - Get the reconstructed data from encoder                  */
194/*****************************************************************************/
195typedef struct
196{
197    ive_get_recon_ip_t                        s_ive_ip;
198}ih264e_get_recon_ip_t;
199
200typedef struct
201{
202    ive_get_recon_op_t                        s_ive_op;
203}ih264e_get_recon_op_t;
204/*****************************************************************************/
205/*   Video control  Flush                                                    */
206/*****************************************************************************/
207
208
209typedef struct
210{
211    ive_ctl_flush_ip_t                      s_ive_ip;
212}ih264e_ctl_flush_ip_t;
213
214
215typedef struct
216{
217    ive_ctl_flush_op_t                      s_ive_op;
218}ih264e_ctl_flush_op_t;
219
220/*****************************************************************************/
221/*   Video control reset                                                     */
222/*****************************************************************************/
223
224
225typedef struct
226{
227    ive_ctl_reset_ip_t                      s_ive_ip;
228}ih264e_ctl_reset_ip_t;
229
230
231typedef struct
232{
233    ive_ctl_reset_op_t                      s_ive_op;
234}ih264e_ctl_reset_op_t;
235
236
237/*****************************************************************************/
238/*   Video control:Get Buf Info                                              */
239/*****************************************************************************/
240
241
242typedef struct
243{
244    ive_ctl_getbufinfo_ip_t             s_ive_ip;
245}ih264e_ctl_getbufinfo_ip_t;
246
247
248
249typedef struct
250{
251    ive_ctl_getbufinfo_op_t             s_ive_op;
252}ih264e_ctl_getbufinfo_op_t;
253
254
255
256/*****************************************************************************/
257/*   Video control:Get Version Info                                          */
258/*****************************************************************************/
259
260
261typedef struct
262{
263    ive_ctl_getversioninfo_ip_t         s_ive_ip;
264}ih264e_ctl_getversioninfo_ip_t;
265
266
267
268typedef struct
269{
270    ive_ctl_getversioninfo_op_t         s_ive_op;
271}ih264e_ctl_getversioninfo_op_t;
272
273/*****************************************************************************/
274/*   Video control:Set default params                                       */
275/*****************************************************************************/
276
277
278typedef struct
279{
280    ive_ctl_setdefault_ip_t         s_ive_ip;
281}ih264e_ctl_setdefault_ip_t;
282
283
284
285typedef struct
286{
287    ive_ctl_setdefault_op_t         s_ive_op;
288}ih264e_ctl_setdefault_op_t;
289
290/*****************************************************************************/
291/*   Video control  Set IPE params                                           */
292/*****************************************************************************/
293typedef struct
294{
295    ive_ctl_set_ipe_params_ip_t     s_ive_ip;
296}ih264e_ctl_set_ipe_params_ip_t;
297
298typedef struct
299{
300    ive_ctl_set_ipe_params_op_t     s_ive_op;
301}ih264e_ctl_set_ipe_params_op_t;
302
303/*****************************************************************************/
304/*   Video control  Set Frame dimensions                                     */
305/*****************************************************************************/
306typedef struct
307{
308    ive_ctl_set_dimensions_ip_t     s_ive_ip;
309}ih264e_ctl_set_dimensions_ip_t;
310
311typedef struct
312{
313    ive_ctl_set_dimensions_op_t     s_ive_op;
314}ih264e_ctl_set_dimensions_op_t;
315
316/*****************************************************************************/
317/*   Video control  Set Frame rates                                          */
318/*****************************************************************************/
319typedef struct
320{
321    ive_ctl_set_frame_rate_ip_t     s_ive_ip;
322}ih264e_ctl_set_frame_rate_ip_t;
323typedef struct
324{
325    ive_ctl_set_frame_rate_op_t     s_ive_op;
326}ih264e_ctl_set_frame_rate_op_t;
327
328
329/*****************************************************************************/
330/*   Video control  Set Bitrate                                              */
331/*****************************************************************************/
332typedef struct
333{
334    ive_ctl_set_bitrate_ip_t        s_ive_ip;
335}ih264e_ctl_set_bitrate_ip_t;
336
337typedef struct
338{
339    ive_ctl_set_bitrate_op_t        s_ive_op;
340}ih264e_ctl_set_bitrate_op_t;
341
342
343/*****************************************************************************/
344/*   Video control  Set Frame type                                           */
345/*****************************************************************************/
346typedef struct
347{
348    ive_ctl_set_frame_type_ip_t     s_ive_ip;
349}ih264e_ctl_set_frame_type_ip_t;
350
351typedef struct
352{
353    ive_ctl_set_frame_type_op_t     s_ive_op;
354}ih264e_ctl_set_frame_type_op_t;
355
356/*****************************************************************************/
357/*   Video control  Set Encode mode                                          */
358/*****************************************************************************/
359typedef struct
360{
361    ive_ctl_set_enc_mode_ip_t       s_ive_ip;
362}ih264e_ctl_set_enc_mode_ip_t;
363
364typedef struct
365{
366    ive_ctl_set_enc_mode_op_t       s_ive_op;
367}ih264e_ctl_set_enc_mode_op_t;
368
369/*****************************************************************************/
370/*   Video control  Set QP                                                   */
371/*****************************************************************************/
372typedef struct
373{
374    ive_ctl_set_qp_ip_t             s_ive_ip;
375}ih264e_ctl_set_qp_ip_t;
376
377typedef struct
378{
379    ive_ctl_set_qp_op_t             s_ive_op;
380}ih264e_ctl_set_qp_op_t;
381
382/*****************************************************************************/
383/*   Video control  Set AIR params                                           */
384/*****************************************************************************/
385typedef struct
386{
387    ive_ctl_set_air_params_ip_t     s_ive_ip;
388}ih264e_ctl_set_air_params_ip_t;
389
390typedef struct
391{
392    ive_ctl_set_air_params_op_t     s_ive_op;
393}ih264e_ctl_set_air_params_op_t;
394
395/*****************************************************************************/
396/*   Video control  Set VBV params                                           */
397/*****************************************************************************/
398typedef struct
399{
400    ive_ctl_set_vbv_params_ip_t     s_ive_ip;
401}ih264e_ctl_set_vbv_params_ip_t;
402
403typedef struct
404{
405    ive_ctl_set_vbv_params_op_t     s_ive_op;
406}ih264e_ctl_set_vbv_params_op_t;
407
408/*****************************************************************************/
409/*   Video control  Set Processor Details                                    */
410/*****************************************************************************/
411typedef struct
412{
413    ive_ctl_set_num_cores_ip_t      s_ive_ip;
414}ih264e_ctl_set_num_cores_ip_t;
415
416typedef struct
417{
418    ive_ctl_set_num_cores_op_t      s_ive_op;
419}ih264e_ctl_set_num_cores_op_t;
420
421/*****************************************************************************/
422/*   Video control  Set Motion estimation params                             */
423/*****************************************************************************/
424typedef struct
425{
426    ive_ctl_set_me_params_ip_t      s_ive_ip;
427}ih264e_ctl_set_me_params_ip_t;
428
429typedef struct
430{
431    ive_ctl_set_me_params_op_t      s_ive_op;
432}ih264e_ctl_set_me_params_op_t;
433
434/*****************************************************************************/
435/*   Video control  Set GOP params                                           */
436/*****************************************************************************/
437typedef struct
438{
439    ive_ctl_set_gop_params_ip_t     s_ive_ip;
440}ih264e_ctl_set_gop_params_ip_t;
441
442typedef struct
443{
444    ive_ctl_set_gop_params_op_t     s_ive_op;
445}ih264e_ctl_set_gop_params_op_t;
446
447/*****************************************************************************/
448/*   Video control  Set Deblock params                                       */
449/*****************************************************************************/
450typedef struct
451{
452    ive_ctl_set_deblock_params_ip_t s_ive_ip;
453}ih264e_ctl_set_deblock_params_ip_t;
454
455typedef struct
456{
457    ive_ctl_set_deblock_params_op_t s_ive_op;
458}ih264e_ctl_set_deblock_params_op_t;
459
460/*****************************************************************************/
461/*   Video control  Set Profile params                                       */
462/*****************************************************************************/
463typedef struct
464{
465    ive_ctl_set_profile_params_ip_t s_ive_ip;
466}ih264e_ctl_set_profile_params_ip_t;
467
468typedef struct
469{
470    ive_ctl_set_profile_params_op_t s_ive_op;
471}ih264e_ctl_set_profile_params_op_t;
472
473/*****************************************************************************/
474/*   Synchronous video encode call                                           */
475/*****************************************************************************/
476typedef struct
477{
478    ive_video_encode_ip_t s_ive_ip;
479}ih264e_video_encode_ip_t;
480
481typedef struct
482{
483    ive_video_encode_op_t s_ive_op;
484}ih264e_video_encode_op_t;
485
486
487/*****************************************************************************/
488/*   Video usability information                                             */
489/*****************************************************************************/
490typedef struct
491{
492    /** size of the structure  */
493    UWORD32                                     u4_size;
494
495    /** Command type : IVE_CMD_VIDEO_CTL  */
496    IVE_API_COMMAND_TYPE_T                      e_cmd;
497
498    /** Sub command type : IVE_CMD_CTL_SET_GOP_PARAMS */
499    IVE_CONTROL_API_COMMAND_TYPE_T              e_sub_cmd;
500
501    /** indicates the presence of aspect_ratio */
502    UWORD8                                      u1_aspect_ratio_info_present_flag;
503
504    /** specifies the aspect ratio of the luma samples */
505    UWORD8                                      u1_aspect_ratio_idc;
506
507    /** width of the luma samples. user dependent */
508    UWORD16                                     u2_sar_width;
509
510    /** Height of the luma samples. user dependent */
511    UWORD16                                     u2_sar_height;
512
513    /** if 1, specifies that the overscan_appropriate_flag is present
514     * if 0, the preferred display method for the video signal is unspecified */
515    UWORD8                                      u1_overscan_info_present_flag;
516
517    /** if 1,indicates that the cropped decoded pictures output
518     * are suitable for display using overscan */
519    UWORD8                                      u1_overscan_appropriate_flag;
520
521    /** if 1 specifies that video_format, video_full_range_flag and
522     * colour_description_present_flag are present */
523    UWORD8                                      u1_video_signal_type_present_flag;
524
525    /** pal, secam, ntsc, ...  */
526    UWORD8                                      u1_video_format;
527
528    /** indicates the black level and range of the luma and chroma signals */
529    UWORD8                                      u1_video_full_range_flag;
530
531    /** if 1,specifies that colour_primaries, transfer_characteristics
532     * and matrix_coefficients are present */
533    UWORD8                                      u1_colour_description_present_flag;
534
535    /** indicates the chromaticity coordinates of the source primaries  */
536    UWORD8                                      u1_colour_primaries;
537
538    /** indicates the opto-electronic transfer characteristic of the source picture */
539    UWORD8                                      u1_transfer_characteristics;
540
541    /** the matrix coefficients used in deriving luma and chroma signals
542     * from the green, blue, and red primaries */
543    UWORD8                                      u1_matrix_coefficients;
544
545    /** if 1, specifies that chroma_sample_loc_type_top_field and
546     * chroma_sample_loc_type_bottom_field are present */
547    UWORD8                                      u1_chroma_loc_info_present_flag;
548
549    /** location of chroma samples */
550    UWORD8                                      u1_chroma_sample_loc_type_top_field;
551    UWORD8                                      u1_chroma_sample_loc_type_bottom_field;
552
553    /**  Indicates the presence of the num_units_in_ticks, time_scale flag */
554    UWORD8                                      u1_vui_timing_info_present_flag;
555
556    /**  Number of units that correspond to one increment of the
557    *   clock. Indicates the  resolution */
558    UWORD32                                     u4_vui_num_units_in_tick;
559
560    /**  The number of time units that pass in one second */
561    UWORD32                                     u4_vui_time_scale;
562
563    /** Flag indicating that time difference between two frames is a constant */
564    UWORD8                                      u1_fixed_frame_rate_flag;
565
566    /** Indicates the presence of NAL HRD parameters */
567    UWORD8                                      u1_nal_hrd_parameters_present_flag;
568
569    /** Indicates the presence of VCL HRD parameters */
570    UWORD8                                      u1_vcl_hrd_parameters_present_flag;
571
572    /** Specifies the HRD operational mode */
573    UWORD8                                      u1_low_delay_hrd_flag;
574
575    /** Indicates presence of SEI messages which include pic_struct syntax element */
576    UWORD8                                      u1_pic_struct_present_flag;
577
578    /** 1, specifies that the following cvs bitstream restriction parameters are present */
579    UWORD8                                      u1_bitstream_restriction_flag;
580
581    /** if 0, indicates that no pel outside the pic boundaries and
582     * no sub-pels derived using pels outside the pic boundaries is used for inter prediction */
583    UWORD8                                      u1_motion_vectors_over_pic_boundaries_flag;
584
585    /** Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units
586     * associated with any coded picture */
587    UWORD8                                      u1_max_bytes_per_pic_denom;
588
589    /** Indicates an upper bound for the number of bits of coding_unit() data */
590    UWORD8                                      u1_max_bits_per_mb_denom;
591
592    /** Indicate the maximum absolute value of a decoded horizontal MV component
593     * in quarter-pel luma units */
594    UWORD8                                      u1_log2_max_mv_length_horizontal;
595
596    /** Indicate the maximum absolute value of a decoded vertical MV component
597     * in quarter-pel luma units */
598    UWORD8                                      u1_log2_max_mv_length_vertical;
599
600    /** Max number of frames that are not synchronized in display and decode order */
601    UWORD8                                      u1_num_reorder_frames;
602
603    /** specifies required size of the HRD DPB in units of frame buffers */
604    UWORD8                                      u1_max_dec_frame_buffering;
605
606}ih264e_vui_ip_t;
607
608typedef struct
609{
610    /** size of the structure                                           */
611    UWORD32                                     u4_size;
612
613    /** Return error code                                               */
614    UWORD32                                     u4_error_code;
615}ih264e_vui_op_t;
616
617
618/* The enum values should not have greater than 8 bits as this is assigned to WORD8 */
619typedef enum
620{
621    INTRA16x16 = 0,
622    INTRA4x4,
623    INTER16x16
624}IV_MB_TYPE_T;
625
626/*****************************************************************************/
627/*   Pic info structures                                                     */
628/*****************************************************************************/
629typedef struct
630{
631    /** Qp  */
632    UWORD32                                     u4_qp;
633
634    /** Pic Type */
635    IV_PICTURE_CODING_TYPE_T                    e_frame_type;
636
637}ih264e_pic_info1_t;
638
639typedef struct
640{
641    /** Qp  */
642    UWORD32                                     u4_qp;
643
644    /** Pic Type */
645    IV_PICTURE_CODING_TYPE_T                    e_frame_type;
646
647    /** Disable deblock level (0: Enable completely, 3: Disable completely */
648    UWORD32                                     u4_disable_deblock_level;
649
650}ih264e_pic_info2_t;
651
652
653/*****************************************************************************/
654/*   MB info structures                                                     */
655/*****************************************************************************/
656typedef struct
657{
658    /** MV X    */
659    WORD16                                  i2_mv_x;
660
661    /** MV Y    */
662    WORD16                                  i2_mv_y;
663}ih264e_mv_t;
664
665typedef struct
666{
667    /** Intra / Inter    */
668    WORD8                                       i1_mb_type;
669    union
670    {
671        ih264e_mv_t                                 as_mv[1];
672
673        /** Intra mode */
674        WORD8                                       ai1_intra_mode[1];
675    };
676}ih264e_mb_info1_t;
677
678typedef struct
679{
680    /** Intra / Inter    */
681    WORD8                                       i1_mb_type;
682
683
684    /** SAD     */
685    UWORD16                                     u2_sad;
686
687    union
688    {
689        ih264e_mv_t                                 as_mv[1];
690
691        /** Intra mode */
692        WORD8                                       ai1_intra_mode[1];
693    };
694
695
696}ih264e_mb_info2_t;
697
698typedef struct
699{
700    /** Intra / Inter    */
701    WORD8                                       i1_mb_type;
702
703    union
704    {
705        ih264e_mv_t                                 as_mv[4];
706
707        /** Intra mode */
708        WORD8                                       ai1_intra_mode[16];
709    };
710
711}ih264e_mb_info3_t;
712
713typedef struct
714{
715    /** Intra / Inter    */
716    WORD8                                       i1_mb_type;
717
718    /** Intra Mode      */
719    WORD8                                       i1_intra_mode;
720
721    /** SAD     */
722    UWORD16                                     u2_sad;
723
724    union
725    {
726        ih264e_mv_t                                 as_mv[16];
727
728        /** Intra mode */
729        WORD8                                       ai1_intra_mode[16];
730    };
731
732
733
734}ih264e_mb_info4_t;
735
736/* Add any new structures to the following union. It is used to calculate the max size needed for allocation of memory */
737typedef struct
738{
739    union
740    {
741        ih264e_mb_info1_t               s_mb_info1;
742        ih264e_mb_info2_t               s_mb_info2;
743        ih264e_mb_info3_t               s_mb_info3;
744        ih264e_mb_info4_t               s_mb_info4;
745    };
746}ih264e_mb_info_t;
747
748#ifdef __cplusplus
749} /* closing brace for extern "C" */
750#endif
751#endif /* _IH264E_H_ */
752