M4VD_EXTERNAL_BitstreamParser.c revision 32ed3f4dad00f8a65f7e6b38402c70d5341c57eb
1/*
2 * Copyright (C) 2004-2011 NXP Software
3 * Copyright (C) 2011 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#include "M4OSA_Types.h"
19#include "M4OSA_Debug.h"
20
21#include "M4VD_EXTERNAL_Interface.h"
22#include "M4VD_EXTERNAL_Internal.h"
23#include "M4VD_Tools.h"
24
25/**
26 ************************************************************************
27 * @file   M4VD_EXTERNAL_BitstreamParser.c
28 * @brief
29 * @note   This file implements external Bitstream parser
30 ************************************************************************
31 */
32
33M4OSA_UInt32 M4VD_EXTERNAL_GetBitsFromMemory(M4VS_Bitstream_ctxt* parsingCtxt,
34     M4OSA_UInt32 nb_bits)
35{
36#if 0
37    M4OSA_UInt32    code;
38    M4OSA_UInt32    i;
39
40    code = 0;
41    for (i = 0; i < nb_bits; i++)
42    {
43        if (parsingCtxt->stream_index == 8)
44        {
45            memcpy( (void *)&(parsingCtxt->stream_byte), (void *)parsingCtxt->in,
46                 sizeof(unsigned char));
47            parsingCtxt->in++;
48            //fread(&stream_byte, sizeof(unsigned char),1,in);
49            parsingCtxt->stream_index = 0;
50        }
51        code = (code << 1);
52        code |= ((parsingCtxt->stream_byte & 0x80) >> 7);
53
54        parsingCtxt->stream_byte = (parsingCtxt->stream_byte << 1);
55        parsingCtxt->stream_index++;
56    }
57
58    return code;
59#endif
60        return(M4VD_Tools_GetBitsFromMemory(parsingCtxt,nb_bits));
61}
62
63M4OSA_ERR M4VD_EXTERNAL_WriteBitsToMemory(M4OSA_UInt32 bitsToWrite,
64                                                 M4OSA_MemAddr32 dest_bits,
65                                                 M4OSA_UInt8 offset, M4OSA_UInt8 nb_bits)
66{
67#if 0
68    M4OSA_UInt8 i,j;
69    M4OSA_UInt32 temp_dest = 0, mask = 0, temp = 1;
70    M4OSA_UInt32 input = bitsToWrite;
71
72    input = (input << (32 - nb_bits - offset));
73
74    /* Put destination buffer to 0 */
75    for(j=0;j<3;j++)
76    {
77        for(i=0;i<8;i++)
78        {
79            if((j*8)+i >= offset && (j*8)+i < nb_bits + offset)
80            {
81                mask |= (temp << ((7*(j+1))-i+j));
82            }
83        }
84    }
85    mask = ~mask;
86    *dest_bits &= mask;
87
88    /* Parse input bits, and fill output buffer */
89    for(j=0;j<3;j++)
90    {
91        for(i=0;i<8;i++)
92        {
93            if((j*8)+i >= offset && (j*8)+i < nb_bits + offset)
94            {
95                temp = ((input & (0x80000000 >> offset)) >> (31-offset));
96                //*dest_bits |= (temp << (31 - i));
97                *dest_bits |= (temp << ((7*(j+1))-i+j));
98                input = (input << 1);
99            }
100        }
101    }
102
103    return M4NO_ERROR;
104#endif
105        return (M4VD_Tools_WriteBitsToMemory( bitsToWrite,dest_bits,
106                                                offset,  nb_bits));
107}
108
109M4OSA_ERR M4DECODER_EXTERNAL_ParseVideoDSI(M4OSA_UInt8* pVol, M4OSA_Int32 aVolSize,
110                                             M4DECODER_MPEG4_DecoderConfigInfo* pDci,
111                                             M4DECODER_VideoSize* pVideoSize)
112{
113    M4VS_Bitstream_ctxt parsingCtxt;
114    M4OSA_UInt32 code, j;
115    M4OSA_MemAddr8 start;
116    M4OSA_UInt8 i;
117    M4OSA_UInt32 time_incr_length;
118    M4OSA_UInt8 vol_verid=0, b_hierarchy_type;
119
120    /* Parsing variables */
121    M4OSA_UInt8 video_object_layer_shape = 0;
122    M4OSA_UInt8 sprite_enable = 0;
123    M4OSA_UInt8 reduced_resolution_vop_enable = 0;
124    M4OSA_UInt8 scalability = 0;
125    M4OSA_UInt8 enhancement_type = 0;
126    M4OSA_UInt8 complexity_estimation_disable = 0;
127    M4OSA_UInt8 interlaced = 0;
128    M4OSA_UInt8 sprite_warping_points = 0;
129    M4OSA_UInt8 sprite_brightness_change = 0;
130    M4OSA_UInt8 quant_precision = 0;
131
132    /* Fill the structure with default parameters */
133    pVideoSize->m_uiWidth              = 0;
134    pVideoSize->m_uiHeight             = 0;
135
136    pDci->uiTimeScale          = 0;
137    pDci->uiProfile            = 0;
138    pDci->uiUseOfResynchMarker = 0;
139    pDci->bDataPartition       = M4OSA_FALSE;
140    pDci->bUseOfRVLC           = M4OSA_FALSE;
141
142    /* Reset the bitstream context */
143    parsingCtxt.stream_byte = 0;
144    parsingCtxt.stream_index = 8;
145    parsingCtxt.in = (M4OSA_Int8 *)pVol;
146
147    start = (M4OSA_Int8 *)pVol;
148
149    /* Start parsing */
150    while (parsingCtxt.in - start < aVolSize)
151    {
152        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 8);
153        if (code == 0)
154        {
155            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 8);
156            if (code == 0)
157            {
158                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 8);
159                if (code == 1)
160                {
161                    /* start code found */
162                    code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 8);
163
164                    /* ----- 0x20..0x2F : video_object_layer_start_code ----- */
165
166                    if ((code > 0x1F) && (code < 0x30))
167                    {
168                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
169                                 1);/* random accessible vol */
170                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
171                                 8);/* video object type indication */
172                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
173                                 1);/* is object layer identifier */
174                        if (code == 1)
175                        {
176                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
177                                     4); /* video object layer verid */
178                            vol_verid = (M4OSA_UInt8)code;
179                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
180                                     3); /* video object layer priority */
181                        }
182                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
183                                 4);/* aspect ratio */
184                        if (code == 15)
185                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
186                                     16); /* par_width and par_height (8+8) */
187                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
188                                 1);/* vol control parameters */
189                        if (code == 1)
190                        {
191                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
192                                     3);/* chroma format + low delay (3+1) */
193                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
194                                     1);/* vbv parameters */
195                            if (code == 1)
196                            {
197                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
198                                         32);/* first and latter half bitrate + 2 marker bits
199                                            (15 + 1 + 15 + 1) */
200                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
201                                         31);/* first and latter half vbv buffer size + first
202                                          half vbv occupancy + marker bits (15+1+3+11+1)*/
203                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
204                                         16);/* first half vbv occupancy + marker bits (15+1)*/
205                            }
206                        }
207                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
208                                 2); /* video object layer shape */
209                        /* Need to save it for vop parsing */
210                        video_object_layer_shape = (M4OSA_UInt8)code;
211
212                        if (code != 0) return 0; /* only rectangular case supported */
213
214                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
215                                 1); /* Marker bit */
216                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
217                                 16); /* VOP time increment resolution */
218                        pDci->uiTimeScale = code;
219
220                        /* Computes time increment length */
221                        j    = code - 1;
222                        for (i = 0; (i < 32) && (j != 0); j >>=1)
223                        {
224                            i++;
225                        }
226                        time_incr_length = (i == 0) ? 1 : i;
227
228                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
229                                 1);/* Marker bit */
230                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
231                                 1);/* Fixed VOP rate */
232                        if (code == 1)
233                        {
234                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
235                                     time_incr_length);/* Fixed VOP time increment */
236                        }
237
238                        if(video_object_layer_shape != 1) /* 1 = Binary */
239                        {
240                            if(video_object_layer_shape == 0) /* 0 = rectangular */
241                            {
242                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
243                                         1);/* Marker bit */
244                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
245                                         13);/* Width */
246                                pVideoSize->m_uiWidth = code;
247                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
248                                         1);/* Marker bit */
249                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
250                                         13);/* Height */
251                                pVideoSize->m_uiHeight = code;
252                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
253                                         1);/* Marker bit */
254                            }
255                        }
256
257                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
258                                 1);/* interlaced */
259                        interlaced = (M4OSA_UInt8)code;
260                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
261                                 1);/* OBMC disable */
262
263                        if(vol_verid == 1)
264                        {
265                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
266                                     1);/* sprite enable */
267                            sprite_enable = (M4OSA_UInt8)code;
268                        }
269                        else
270                        {
271                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
272                                     2);/* sprite enable */
273                            sprite_enable = (M4OSA_UInt8)code;
274                        }
275                        if ((sprite_enable == 1) || (sprite_enable == 2))
276                        /* Sprite static = 1 and Sprite GMC = 2 */
277                        {
278                            if (sprite_enable != 2)
279                            {
280
281                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
282                                         13);/* sprite width */
283                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
284                                         1);/* Marker bit */
285                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
286                                         13);/* sprite height */
287                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
288                                         1);/* Marker bit */
289                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
290                                         13);/* sprite l coordinate */
291                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
292                                         1);/* Marker bit */
293                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
294                                         13);/* sprite top coordinate */
295                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
296                                         1);/* Marker bit */
297                            }
298
299                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
300                                     6);/* sprite warping points */
301                            sprite_warping_points = (M4OSA_UInt8)code;
302                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
303                                     2);/* sprite warping accuracy */
304                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
305                                     1);/* sprite brightness change */
306                            sprite_brightness_change = (M4OSA_UInt8)code;
307                            if (sprite_enable != 2)
308                            {
309                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
310                                             1);/* low latency sprite enable */
311                            }
312                        }
313                        if ((vol_verid != 1) && (video_object_layer_shape != 0))
314                        {
315                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
316                                         1);/* sadct disable */
317                        }
318
319                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1); /* not 8 bits */
320                        if (code)
321                        {
322                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
323                                     4);/* quant precision */
324                            quant_precision = (M4OSA_UInt8)code;
325                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
326                                         4);/* bits per pixel */
327                        }
328
329                        /* greyscale not supported */
330                        if(video_object_layer_shape == 3)
331                        {
332                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
333                                     3); /* nogray quant update + composition method +
334                                            linear composition */
335                        }
336
337                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
338                                     1);/* quant type */
339                        if (code)
340                        {
341                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
342                                         1);/* load intra quant mat */
343                            if (code)
344                            {
345                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 8);/* */
346                                 i    = 1;
347                                while (i < 64)
348                                {
349                                    code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 8);
350                                    if (code == 0)
351                                        break;
352                                    i++;
353                                }
354                            }
355
356                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
357                                         1);/* load non intra quant mat */
358                            if (code)
359                            {
360                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 8);/* */
361                                 i    = 1;
362                                while (i < 64)
363                                {
364                                    code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 8);
365                                    if (code == 0)
366                                        break;
367                                    i++;
368                                }
369                            }
370                        }
371
372                        if (vol_verid != 1)
373                        {
374                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
375                                     1);/* quarter sample */
376                        }
377
378                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
379                                     1);/* complexity estimation disable */
380                        complexity_estimation_disable = (M4OSA_UInt8)code;
381                        if (!code)
382                        {
383                            //return M4ERR_NOT_IMPLEMENTED;
384                        }
385
386                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
387                                     1);/* resync marker disable */
388                        pDci->uiUseOfResynchMarker = (code) ? 0 : 1;
389
390                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt,
391                                     1);/* data partitionned */
392                        pDci->bDataPartition = (code) ? M4OSA_TRUE : M4OSA_FALSE;
393                        if (code)
394                        {
395                            /* reversible VLC */
396                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1);
397                            pDci->bUseOfRVLC = (code) ? M4OSA_TRUE : M4OSA_FALSE;
398                        }
399
400                        if (vol_verid != 1)
401                        {
402                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1);/* newpred */
403                            if (code)
404                            {
405                                //return M4ERR_PARAMETER;
406                            }
407                            /* reduced resolution vop enable */
408                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1);
409                            reduced_resolution_vop_enable = (M4OSA_UInt8)code;
410                        }
411
412                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1);/* scalability */
413                        scalability = (M4OSA_UInt8)code;
414                        if (code)
415                        {
416                            /* hierarchy type */
417                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1);
418                            b_hierarchy_type = (M4OSA_UInt8)code;
419                            /* ref layer id */
420                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 4);
421                            /* ref sampling direct */
422                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1);
423                            /* hor sampling factor N */
424                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 5);
425                            /* hor sampling factor M */
426                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 5);
427                            /* vert sampling factor N */
428                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 5);
429                            /* vert sampling factor M */
430                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 5);
431                            /* enhancement type */
432                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1);
433                            enhancement_type = (M4OSA_UInt8)code;
434                            if ((!b_hierarchy_type) && (video_object_layer_shape == 1))
435                            {
436                                /* use ref shape */
437                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1);
438                                /* use ref texture */
439                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1);
440                                /* shape hor sampling factor N */
441                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 5);
442                                /* shape hor sampling factor M */
443                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 5);
444                                /* shape vert sampling factor N */
445                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 5);
446                                /* shape vert sampling factor M */
447                                code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 5);
448                            }
449                        }
450                        break;
451                    }
452
453                    /* ----- 0xB0 : visual_object_sequence_start_code ----- */
454
455                    else if(code == 0xB0)
456                    {
457                        /* profile_and_level_indication */
458                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 8);
459                        pDci->uiProfile = (M4OSA_UInt8)code;
460                    }
461
462                    /* ----- 0xB5 : visual_object_start_code ----- */
463
464                    else if(code == 0xB5)
465                    {
466                        /* is object layer identifier */
467                        code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 1);
468                        if (code == 1)
469                        {
470                             /* visual object verid */
471                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 4);
472                            vol_verid = (M4OSA_UInt8)code;
473                             /* visual object layer priority */
474                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 3);
475                        }
476                        else
477                        {
478                             /* Realign on byte */
479                            code = M4VD_EXTERNAL_GetBitsFromMemory(&parsingCtxt, 7);
480                            vol_verid = 1;
481                        }
482                    }
483
484                    /* ----- end ----- */
485                }
486                else
487                {
488                    if ((code >> 2) == 0x20)
489                    {
490                        /* H263 ...-> wrong*/
491                        break;
492                    }
493                }
494            }
495        }
496    }
497
498    return M4NO_ERROR;
499}
500
501M4OSA_ERR M4DECODER_EXTERNAL_ParseAVCDSI(M4OSA_UInt8* pDSI, M4OSA_Int32 DSISize,
502                                         M4DECODER_AVCProfileLevel *profile)
503{
504    M4OSA_ERR err = M4NO_ERROR;
505    M4OSA_Bool NALSPS_and_Profile0Found = M4OSA_FALSE;
506    M4OSA_UInt16 index = 28; /* the 29th byte is SPS start */
507    M4OSA_Bool constraintSet3;
508
509    if (DSISize <= index) {
510        M4OSA_TRACE1_0("M4DECODER_EXTERNAL_ParseAVCDSI: DSI is invalid");
511        *profile = M4DECODER_AVC_kProfile_and_Level_Out_Of_Range;
512        return M4ERR_PARAMETER;
513    }
514
515    /* check for baseline profile */
516    if(((pDSI[index] & 0x1f) == 0x07) && (pDSI[index+1] == 0x42))
517    {
518        NALSPS_and_Profile0Found = M4OSA_TRUE;
519    }
520
521    if(M4OSA_FALSE == NALSPS_and_Profile0Found)
522    {
523        M4OSA_TRACE1_1("M4DECODER_EXTERNAL_ParseAVCDSI: index bad = %d", index);
524        *profile = M4DECODER_AVC_kProfile_and_Level_Out_Of_Range;
525    }
526    else
527    {
528        M4OSA_TRACE1_1("M4DECODER_EXTERNAL_ParseAVCDSI: index = %d", index);
529        constraintSet3 = (pDSI[index+2] & 0x10);
530        M4OSA_TRACE1_1("M4DECODER_EXTERNAL_ParseAVCDSI: level = %d", pDSI[index+3]);
531        switch(pDSI[index+3])
532        {
533        case 10:
534            *profile = M4DECODER_AVC_kProfile_0_Level_1;
535            break;
536        case 11:
537            if(constraintSet3)
538                *profile = M4DECODER_AVC_kProfile_0_Level_1b;
539            else
540                *profile = M4DECODER_AVC_kProfile_0_Level_1_1;
541            break;
542        case 12:
543            *profile = M4DECODER_AVC_kProfile_0_Level_1_2;
544            break;
545        case 13:
546            *profile = M4DECODER_AVC_kProfile_0_Level_1_3;
547            break;
548        case 20:
549            *profile = M4DECODER_AVC_kProfile_0_Level_2;
550            break;
551        case 21:
552            *profile = M4DECODER_AVC_kProfile_0_Level_2_1;
553            break;
554        case 22:
555            *profile = M4DECODER_AVC_kProfile_0_Level_2_2;
556            break;
557        case 30:
558            *profile = M4DECODER_AVC_kProfile_0_Level_3;
559            break;
560        case 31:
561            *profile = M4DECODER_AVC_kProfile_0_Level_3_1;
562            break;
563        case 32:
564            *profile = M4DECODER_AVC_kProfile_0_Level_3_2;
565            break;
566        case 40:
567            *profile = M4DECODER_AVC_kProfile_0_Level_4;
568            break;
569        case 41:
570            *profile = M4DECODER_AVC_kProfile_0_Level_4_1;
571            break;
572        case 42:
573            *profile = M4DECODER_AVC_kProfile_0_Level_4_2;
574            break;
575        case 50:
576            *profile = M4DECODER_AVC_kProfile_0_Level_5;
577            break;
578        case 51:
579            *profile = M4DECODER_AVC_kProfile_0_Level_5_1;
580            break;
581        default:
582            *profile = M4DECODER_AVC_kProfile_and_Level_Out_Of_Range;
583        }
584    }
585    return err;
586}
587
588