1 /*
2  * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
3  * Copyright (c) Imagination Technologies Limited, UK
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sub license, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial portions
15  * of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
21  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  *
25  * Authors:
26  *    Zeng Li <zeng.li@intel.com>
27  *    Shengquan Yuan  <shengquan.yuan@intel.com>
28  *    Binglin Chen <binglin.chen@intel.com>
29  *
30  */
31 
32 #include "psb_def.h"
33 #include "psb_surface.h"
34 #include "psb_cmdbuf.h"
35 #include "lnc_H263ES.h"
36 #include "lnc_hostheader.h"
37 #include "lnc_hostcode.h"
38 #include "psb_drv_debug.h"
39 
40 #include <stdlib.h>
41 #include <stdint.h>
42 #include <string.h>
43 
44 
45 #define TOPAZ_H263_MAX_BITRATE 16000000
46 
47 #define INIT_CONTEXT_H263ES    context_ENC_p ctx = (context_ENC_p) (obj_context->format_data)
48 #define SURFACE(id)    ((object_surface_p) object_heap_lookup( &ctx->obj_context->driver_data->surface_heap, id ))
49 #define BUFFER(id)  ((object_buffer_p) object_heap_lookup( &ctx->obj_context->driver_data->buffer_heap, id ))
50 
51 
lnc_H263ES_QueryConfigAttributes(VAProfile profile,VAEntrypoint entrypoint,VAConfigAttrib * attrib_list,int num_attribs)52 static void lnc_H263ES_QueryConfigAttributes(
53     VAProfile profile,
54     VAEntrypoint entrypoint,
55     VAConfigAttrib *attrib_list,
56     int num_attribs)
57 {
58     int i;
59     drv_debug_msg(VIDEO_DEBUG_GENERAL, "lnc_H263ES_QueryConfigAttributes\n");
60 
61     /* RateControl attributes */
62     for (i = 0; i < num_attribs; i++) {
63         switch (attrib_list[i].type) {
64         case VAConfigAttribRTFormat:
65             break;
66 
67         case VAConfigAttribRateControl:
68             attrib_list[i].value = VA_RC_NONE | VA_RC_CBR | VA_RC_VBR;
69             break;
70 #if 0
71         case VAConfigAttribEncMaxSliceSize:
72             attrib_list[i].value = 0;
73             break;
74 #endif
75         default:
76             attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED;
77             break;
78         }
79     }
80 
81 }
82 
83 
lnc_H263ES_ValidateConfig(object_config_p obj_config)84 static VAStatus lnc_H263ES_ValidateConfig(
85     object_config_p obj_config)
86 {
87     int i;
88     /* Check all attributes */
89     for (i = 0; i < obj_config->attrib_count; i++) {
90         switch (obj_config->attrib_list[i].type) {
91         case VAConfigAttribRTFormat:
92             /* Ignore */
93             break;
94         case VAConfigAttribRateControl:
95             break;
96         default:
97             return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED;
98         }
99     }
100 
101     return VA_STATUS_SUCCESS;
102 }
103 
104 
lnc_H263ES_CreateContext(object_context_p obj_context,object_config_p obj_config)105 static VAStatus lnc_H263ES_CreateContext(
106     object_context_p obj_context,
107     object_config_p obj_config)
108 {
109     VAStatus vaStatus = VA_STATUS_SUCCESS;
110     unsigned int eRCmode;
111     context_ENC_p ctx;
112     int i;
113 
114     drv_debug_msg(VIDEO_DEBUG_GENERAL, "lnc_H263ES_CreateContext\n");
115 
116     vaStatus = lnc_CreateContext(obj_context, obj_config);/* alloc context_ENC_s and BO */
117 
118     if (VA_STATUS_SUCCESS != vaStatus)
119         return VA_STATUS_ERROR_ALLOCATION_FAILED;
120 
121     ctx = (context_ENC_p) obj_context->format_data;
122 
123     ctx->max_slice_size = 0;
124     eRCmode = VA_RC_NONE;
125 
126     for (i = 0; i < obj_config->attrib_count; i++) {
127 #if 0
128         if (obj_config->attrib_list[i].type == VAConfigAttribEncMaxSliceSize)
129             ctx->max_slice_size = obj_config->attrib_list[i].value;
130         else if (obj_config->attrib_list[i].type == VAConfigAttribRateControl)
131             eRCmode = obj_config->attrib_list[i].value;
132 #else
133         if (obj_config->attrib_list[i].type == VAConfigAttribRateControl)
134             eRCmode = obj_config->attrib_list[i].value;
135 #endif
136     }
137 
138     if (eRCmode == VA_RC_VBR) {
139         ctx->eCodec = IMG_CODEC_H263_VBR;
140         ctx->sRCParams.RCEnable = IMG_TRUE;
141     } else if (eRCmode == VA_RC_CBR) {
142         ctx->eCodec = IMG_CODEC_H263_CBR;
143         ctx->sRCParams.RCEnable = IMG_TRUE;
144     } else if (eRCmode == VA_RC_NONE) {
145         ctx->eCodec = IMG_CODEC_H263_NO_RC;
146         ctx->sRCParams.RCEnable = IMG_FALSE;
147     } else
148         return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
149     ctx->eFormat = IMG_CODEC_PL12;
150 
151     ctx->IPEControl = lnc__get_ipe_control(ctx->eCodec);
152 
153     ctx->OptionalCustomPCF = 0;
154 
155     return vaStatus;
156 
157 
158 }
159 
160 
lnc_H263ES_DestroyContext(object_context_p obj_context)161 static void lnc_H263ES_DestroyContext(
162     object_context_p obj_context)
163 {
164 
165     drv_debug_msg(VIDEO_DEBUG_GENERAL, "lnc_H263ES_DestroyContext\n");
166 
167     lnc_DestroyContext(obj_context);
168 }
169 
lnc_H263ES_BeginPicture(object_context_p obj_context)170 static VAStatus lnc_H263ES_BeginPicture(
171     object_context_p obj_context)
172 {
173     VAStatus vaStatus = VA_STATUS_SUCCESS;
174 
175     INIT_CONTEXT_H263ES;
176 
177     drv_debug_msg(VIDEO_DEBUG_GENERAL, "lnc_H263ES_BeginPicture\n");
178 
179     vaStatus = lnc_BeginPicture(ctx);
180 
181     return vaStatus;
182 }
183 
184 
lnc__H263ES_process_sequence_param(context_ENC_p ctx,object_buffer_p obj_buffer)185 static VAStatus lnc__H263ES_process_sequence_param(context_ENC_p ctx, object_buffer_p obj_buffer)
186 {
187     /*
188      * process rate control parameters
189      */
190     VAEncSequenceParameterBufferH263 *pSequenceParams;
191 
192     ASSERT(obj_buffer->type == VAEncSequenceParameterBufferType);
193     ASSERT(obj_buffer->num_elements == 1);
194     ASSERT(obj_buffer->size == sizeof(VAEncSequenceParameterBufferH263));
195 
196     if ((obj_buffer->num_elements != 1) ||
197         (obj_buffer->size != sizeof(VAEncSequenceParameterBufferH263))) {
198         return VA_STATUS_ERROR_UNKNOWN;
199     }
200 
201     pSequenceParams = (VAEncSequenceParameterBufferH263 *) obj_buffer->buffer_data;
202     obj_buffer->buffer_data = NULL;
203     obj_buffer->size = 0;
204 
205     if ((ctx->obj_context->frame_count != 0) &&
206         (ctx->sRCParams.BitsPerSecond != pSequenceParams->bits_per_second))
207         ctx->update_rc_control = 1;
208 
209     if (pSequenceParams->bits_per_second > TOPAZ_H263_MAX_BITRATE) {
210         ctx->sRCParams.BitsPerSecond = TOPAZ_H263_MAX_BITRATE;
211         drv_debug_msg(VIDEO_DEBUG_GENERAL, " bits_per_second(%d) exceeds \
212 		the maximum bitrate, set it with %d\n",
213                                  pSequenceParams->bits_per_second,
214                                  TOPAZ_H263_MAX_BITRATE);
215     } else
216         ctx->sRCParams.BitsPerSecond = pSequenceParams->bits_per_second;
217 
218     if (pSequenceParams->initial_qp < 3)
219         pSequenceParams->initial_qp = 3;
220 
221     ctx->sRCParams.FrameRate = pSequenceParams->frame_rate;
222     ctx->sRCParams.InitialQp = pSequenceParams->initial_qp;
223     ctx->sRCParams.MinQP = pSequenceParams->min_qp;
224     ctx->sRCParams.BUSize = 0; /* default 0, and will be set in lnc__setup_busize */
225 
226 
227     IMG_UINT16 MBRows = 0;
228     if (ctx->Height <= 400)
229         MBRows = 1;
230     else if (ctx->Height < 800)
231         MBRows = 2;
232 
233     ctx->sRCParams.Slices = (ctx->Height + 15) >> (4 + (MBRows >> 1));
234 
235     ctx->sRCParams.IntraFreq = pSequenceParams->intra_period;
236 
237     free(pSequenceParams);
238     return VA_STATUS_SUCCESS;
239 }
240 
241 
242 /* Work done by the followinig funcs in testbench should be done here.
243  * IMG_C_StartPicture()
244  * IMG_C_InsertSync()
245  * APP_H263_SendPictureHeader()
246  * Frame skip must be taken into consideration
247  * */
lnc__H263ES_process_picture_param(context_ENC_p ctx,object_buffer_p obj_buffer)248 static VAStatus lnc__H263ES_process_picture_param(context_ENC_p ctx, object_buffer_p obj_buffer)
249 {
250     VAStatus vaStatus;
251     VAEncPictureParameterBufferH263 *pBuffer;
252     lnc_cmdbuf_p cmdbuf = ctx->obj_context->lnc_cmdbuf;
253     H263_SOURCE_FORMAT_TYPE SourceFormatType;
254 
255     ASSERT(obj_buffer->type == VAEncPictureParameterBufferType);
256 
257     if ((obj_buffer->num_elements != 1) ||
258         (obj_buffer->size != sizeof(VAEncPictureParameterBufferH263))) {
259         return VA_STATUS_ERROR_UNKNOWN;
260     }
261 
262     /* Transfer ownership of VAEncPictureParameterBufferH263 data */
263     pBuffer = (VAEncPictureParameterBufferH263 *) obj_buffer->buffer_data;
264     obj_buffer->buffer_data = NULL;
265     obj_buffer->size = 0;
266 
267     ctx->ref_surface = SURFACE(pBuffer->reference_picture);
268     ctx->dest_surface = SURFACE(pBuffer->reconstructed_picture);
269     ctx->coded_buf = BUFFER(pBuffer->coded_buf);
270 
271     ASSERT(ctx->Width == pBuffer->picture_width);
272     ASSERT(ctx->Height == pBuffer->picture_height);
273 
274     /* Insert do_header command here */
275 
276     if ((ctx->Width == 128) && (ctx->Height == 96))
277         SourceFormatType = _128x96_SubQCIF;
278     else if ((ctx->Width == 176) && (ctx->Height == 144))
279         SourceFormatType = _176x144_QCIF;
280     else if ((ctx->Width == 352) && (ctx->Height == 288))
281         SourceFormatType = _352x288_CIF;
282     else if ((ctx->Width == 704) && (ctx->Height == 576))
283         SourceFormatType = _704x576_4CIF;
284     else if ((ctx->Width <= 720) && (ctx->Height <= 576))
285         SourceFormatType = 7;
286     else {
287         drv_debug_msg(VIDEO_DEBUG_GENERAL, "Unsupported resolution!\n");
288         return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
289     }
290 
291     /* save current cmdbuf write pointer for H263 frameskip redo
292      * for H263, for a skipped frame, picture header/slice header both needn't
293      */
294     cmdbuf->cmd_idx_saved_frameskip = cmdbuf->cmd_idx;
295     if (!(ctx->sRCParams.RCEnable && ctx->sRCParams.FrameSkip)) {
296         lnc__H263_prepare_picture_header((IMG_UINT32 *)(cmdbuf->header_mem_p + ctx->pic_header_ofs),
297                                          ctx->obj_context->frame_count,
298                                          pBuffer->picture_type,
299                                          SourceFormatType,
300                                          ctx->sRCParams.FrameRate,
301                                          ctx->Width,
302                                          ctx->Height,
303                                          &ctx->OptionalCustomPCF);
304 
305         lnc_cmdbuf_insert_command(cmdbuf, MTX_CMDID_DO_HEADER, 2, 1);
306         RELOC_CMDBUF(cmdbuf->cmd_idx++, ctx->pic_header_ofs, &cmdbuf->header_mem);
307     }
308 
309     vaStatus = lnc_RenderPictureParameter(ctx);
310 
311     free(pBuffer);
312     return vaStatus;
313 }
314 
315 
lnc__H263ES_process_slice_param(context_ENC_p ctx,object_buffer_p obj_buffer)316 static VAStatus lnc__H263ES_process_slice_param(context_ENC_p ctx, object_buffer_p obj_buffer)
317 {
318     /* Prepare InParams for macros of current slice, insert slice header, insert do slice command */
319     VAEncSliceParameterBuffer *pBuffer;
320     lnc_cmdbuf_p cmdbuf = ctx->obj_context->lnc_cmdbuf;
321     PIC_PARAMS *psPicParams = (PIC_PARAMS *)(cmdbuf->pic_params_p);
322     unsigned int i;
323     int slice_param_idx;
324 
325     ASSERT(obj_buffer->type == VAEncSliceParameterBufferType);
326 
327     /* do nothing for skip frame if RC enabled */
328     if ((ctx->sRCParams.RCEnable && ctx->sRCParams.FrameSkip)) {
329         free(obj_buffer->buffer_data);
330         obj_buffer->buffer_data = NULL;
331         return VA_STATUS_SUCCESS;
332     }
333 
334     /* Transfer ownership of VAEncPictureParameterBufferH263 data */
335     pBuffer = (VAEncSliceParameterBuffer *) obj_buffer->buffer_data;
336     obj_buffer->size = 0;
337 
338     if (0 == pBuffer->start_row_number) {
339         if (pBuffer->slice_flags.bits.is_intra)
340             RELOC_PIC_PARAMS(&psPicParams->InParamsBase, ctx->in_params_ofs, cmdbuf->topaz_in_params_I);
341         else
342             RELOC_PIC_PARAMS(&psPicParams->InParamsBase, ctx->in_params_ofs, cmdbuf->topaz_in_params_P);
343     }
344 
345     /*In case the slice number changes*/
346     if ((ctx->slice_param_cache != NULL) && (obj_buffer->num_elements != ctx->slice_param_num)) {
347         drv_debug_msg(VIDEO_DEBUG_GENERAL, "Slice number changes. Previous value is %d. Now it's %d\n",
348                                  ctx->slice_param_num, obj_buffer->num_elements);
349         free(ctx->slice_param_cache);
350         ctx->slice_param_cache = NULL;
351         ctx->slice_param_num = 0;
352     }
353 
354     if (NULL == ctx->slice_param_cache) {
355         ctx->slice_param_num = obj_buffer->num_elements;
356         drv_debug_msg(VIDEO_DEBUG_GENERAL, "Allocate %d VAEncSliceParameterBuffer cache buffers\n", 2 * ctx->slice_param_num);
357         ctx->slice_param_cache = calloc(2 * ctx->slice_param_num, sizeof(VAEncSliceParameterBuffer));
358         if (NULL == ctx->slice_param_cache) {
359             drv_debug_msg(VIDEO_DEBUG_ERROR, "Run out of memory!\n");
360             free(obj_buffer->buffer_data);
361             return VA_STATUS_ERROR_ALLOCATION_FAILED;
362         }
363     }
364 
365     for (i = 0; i < obj_buffer->num_elements; i++) {
366         /*Todo list:
367              *1.Insert Do header command
368              *2.setup InRowParams
369              *3.setup Slice params
370              *4.Insert Do slice command
371              * */
372 
373         /* Insert Do Header command, relocation is needed */
374         if (ctx->obj_context->slice_count) {  /*First slice of a frame need not slice header*/
375             lnc__H263_prepare_GOBslice_header(
376                 (IMG_UINT32 *)(cmdbuf->header_mem_p + ctx->slice_header_ofs + ctx->obj_context->slice_count * HEADER_SIZE),
377                 ctx->obj_context->slice_count,
378                 ctx->obj_context->frame_count);
379 
380             lnc_cmdbuf_insert_command(cmdbuf, MTX_CMDID_DO_HEADER, 2, (ctx->obj_context->slice_count << 2) | 2);
381             RELOC_CMDBUF(cmdbuf->cmd_idx++,
382                          ctx->slice_header_ofs + ctx->obj_context->slice_count * HEADER_SIZE,
383                          &cmdbuf->header_mem);
384         }
385 
386         if ((ctx->obj_context->frame_count == 0) && (pBuffer->start_row_number == 0) && pBuffer->slice_flags.bits.is_intra)
387             lnc_reset_encoder_params(ctx);
388 
389         /*The corresponding slice buffer cache*/
390         slice_param_idx = (pBuffer->slice_flags.bits.is_intra ? 0 : 1) * ctx->slice_param_num + i;
391 
392         if (VAEncSliceParameter_Equal(&ctx->slice_param_cache[slice_param_idx], pBuffer) == 0) {
393             /* cache current param parameters */
394             memcpy(&ctx->slice_param_cache[slice_param_idx],
395                    pBuffer, sizeof(VAEncSliceParameterBuffer));
396 
397             /* Setup InParams value*/
398             lnc_setup_slice_params(ctx,
399                                    pBuffer->start_row_number * 16,
400                                    pBuffer->slice_height * 16,
401                                    pBuffer->slice_flags.bits.is_intra,
402                                    ctx->obj_context->frame_count > 0,
403                                    psPicParams->sInParams.SeInitQP);
404         }
405 
406         /* Insert do slice command and setup related buffer value */
407         lnc__send_encode_slice_params(ctx,
408                                       pBuffer->slice_flags.bits.is_intra,
409                                       pBuffer->start_row_number * 16,
410                                       0, /* no deblock for H263 */
411                                       ctx->obj_context->frame_count,
412                                       pBuffer->slice_height * 16,
413                                       ctx->obj_context->slice_count,
414                                       ctx->max_slice_size);
415 
416         drv_debug_msg(VIDEO_DEBUG_GENERAL, "Now frame_count/slice_count is %d/%d\n",
417                                  ctx->obj_context->frame_count, ctx->obj_context->slice_count);
418 
419         ctx->obj_context->slice_count++;
420         pBuffer++;        /*Move to the next buffer*/
421 
422         ASSERT(ctx->obj_context->slice_count < MAX_SLICES_PER_PICTURE);
423     }
424 
425     free(obj_buffer->buffer_data);
426     obj_buffer->buffer_data = NULL;
427     return VA_STATUS_SUCCESS;
428 }
429 
lnc__H263ES_process_misc_param(context_ENC_p ctx,object_buffer_p obj_buffer)430 static VAStatus lnc__H263ES_process_misc_param(context_ENC_p ctx, object_buffer_p obj_buffer)
431 {
432     /* Prepare InParams for macros of current slice, insert slice header, insert do slice command */
433     VAEncMiscParameterBuffer *pBuffer;
434     VAEncMiscParameterRateControl *rate_control_param;
435     VAEncMiscParameterAIR *air_param;
436     VAEncMiscParameterMaxSliceSize *max_slice_size_param;
437     VAEncMiscParameterFrameRate *frame_rate_param;
438 
439     VAStatus vaStatus = VA_STATUS_SUCCESS;
440 
441     ASSERT(obj_buffer->type == VAEncMiscParameterBufferType);
442 
443     pBuffer = (VAEncMiscParameterBuffer *) obj_buffer->buffer_data;
444     obj_buffer->size = 0;
445 
446     switch (pBuffer->type) {
447     case VAEncMiscParameterTypeFrameRate:
448         frame_rate_param = (VAEncMiscParameterFrameRate *)pBuffer->data;
449         drv_debug_msg(VIDEO_DEBUG_GENERAL, "%s: frame rate changed to %d\n",
450                                  frame_rate_param->framerate);
451         break;
452 
453     case VAEncMiscParameterTypeRateControl:
454         rate_control_param = (VAEncMiscParameterRateControl *)pBuffer->data;
455 
456         drv_debug_msg(VIDEO_DEBUG_GENERAL, "%s: bit rate changed to %d\n",
457                                  rate_control_param->bits_per_second);
458 
459         if (rate_control_param->bits_per_second == ctx->sRCParams.BitsPerSecond)
460             break;
461         else
462             ctx->update_rc_control = 1;
463 
464         if (rate_control_param->bits_per_second > TOPAZ_H263_MAX_BITRATE) {
465             ctx->sRCParams.BitsPerSecond = TOPAZ_H263_MAX_BITRATE;
466             drv_debug_msg(VIDEO_DEBUG_GENERAL, " bits_per_second(%d) exceeds \
467 		the maximum bitrate, set it with %d\n",
468                                      rate_control_param->bits_per_second,
469                                      TOPAZ_H263_MAX_BITRATE);
470         } else
471             ctx->sRCParams.BitsPerSecond = rate_control_param->bits_per_second;
472 
473         break;
474 
475     case VAEncMiscParameterTypeMaxSliceSize:
476         max_slice_size_param = (VAEncMiscParameterMaxSliceSize *)pBuffer->data;
477 
478         if (ctx->max_slice_size == max_slice_size_param->max_slice_size)
479             break;
480 
481         drv_debug_msg(VIDEO_DEBUG_GENERAL, "%s: max slice size changed to %d\n",
482                                  max_slice_size_param->max_slice_size);
483 
484         ctx->max_slice_size = max_slice_size_param->max_slice_size;
485 
486         break;
487 
488     case VAEncMiscParameterTypeAIR:
489         air_param = (VAEncMiscParameterAIR *)pBuffer->data;
490 
491         drv_debug_msg(VIDEO_DEBUG_GENERAL, "%s: air slice size changed to num_air_mbs %d "
492                                  "air_threshold %d, air_auto %d\n",
493                                  air_param->air_num_mbs, air_param->air_threshold,
494                                  air_param->air_auto);
495 
496         ctx->num_air_mbs = air_param->air_num_mbs;
497         ctx->air_threshold = air_param->air_threshold;
498         ctx->autotune_air_flag = air_param->air_auto;
499 
500         break;
501 
502     default:
503         vaStatus = VA_STATUS_ERROR_UNKNOWN;
504         DEBUG_FAILURE;
505         break;
506     }
507 
508     free(obj_buffer->buffer_data);
509     obj_buffer->buffer_data = NULL;
510 
511     return VA_STATUS_SUCCESS;
512 }
513 
lnc_H263ES_RenderPicture(object_context_p obj_context,object_buffer_p * buffers,int num_buffers)514 static VAStatus lnc_H263ES_RenderPicture(
515     object_context_p obj_context,
516     object_buffer_p *buffers,
517     int num_buffers)
518 {
519     int i;
520     INIT_CONTEXT_H263ES;
521     VAStatus vaStatus = VA_STATUS_SUCCESS;
522 
523     drv_debug_msg(VIDEO_DEBUG_GENERAL, "lnc_H263ES_RenderPicture\n");
524 
525     for (i = 0; i < num_buffers; i++) {
526         object_buffer_p obj_buffer = buffers[i];
527 
528         switch (obj_buffer->type) {
529         case VAEncSequenceParameterBufferType:
530             drv_debug_msg(VIDEO_DEBUG_GENERAL, "lnc_H263_RenderPicture got VAEncSequenceParameterBufferType\n");
531             vaStatus = lnc__H263ES_process_sequence_param(ctx, obj_buffer);
532             DEBUG_FAILURE;
533             break;
534 
535         case VAEncPictureParameterBufferType:
536             drv_debug_msg(VIDEO_DEBUG_GENERAL, "lnc_H263_RenderPicture got VAEncPictureParameterBuffer\n");
537             vaStatus = lnc__H263ES_process_picture_param(ctx, obj_buffer);
538             DEBUG_FAILURE;
539             break;
540 
541         case VAEncSliceParameterBufferType:
542             drv_debug_msg(VIDEO_DEBUG_GENERAL, "lnc_H263_RenderPicture got VAEncSliceParameterBufferType\n");
543             vaStatus = lnc__H263ES_process_slice_param(ctx, obj_buffer);
544             DEBUG_FAILURE;
545             break;
546 
547         case VAEncMiscParameterBufferType:
548             drv_debug_msg(VIDEO_DEBUG_GENERAL, "lnc_H263ES_RenderPicture got VAEncMiscParameterBufferType\n");
549             vaStatus = lnc__H263ES_process_misc_param(ctx, obj_buffer);
550             DEBUG_FAILURE;
551             break;
552 
553         default:
554             vaStatus = VA_STATUS_ERROR_UNKNOWN;
555             DEBUG_FAILURE;
556         }
557         if (vaStatus != VA_STATUS_SUCCESS) {
558             break;
559         }
560     }
561 
562 
563     return vaStatus;
564 }
565 
lnc_H263ES_EndPicture(object_context_p obj_context)566 static VAStatus lnc_H263ES_EndPicture(
567     object_context_p obj_context)
568 {
569     VAStatus vaStatus = VA_STATUS_SUCCESS;
570     INIT_CONTEXT_H263ES;
571 
572     drv_debug_msg(VIDEO_DEBUG_GENERAL, "lnc_H263ES_EndPicture\n");
573 
574     vaStatus = lnc_EndPicture(ctx);
575 
576     return vaStatus;
577 }
578 
579 
580 struct format_vtable_s lnc_H263ES_vtable = {
581 queryConfigAttributes:
582     lnc_H263ES_QueryConfigAttributes,
583 validateConfig:
584     lnc_H263ES_ValidateConfig,
585 createContext:
586     lnc_H263ES_CreateContext,
587 destroyContext:
588     lnc_H263ES_DestroyContext,
589 beginPicture:
590     lnc_H263ES_BeginPicture,
591 renderPicture:
592     lnc_H263ES_RenderPicture,
593 endPicture:
594     lnc_H263ES_EndPicture
595 };
596