1 /*
2 * Copyright (c) 2009-2011 Intel Corporation.  All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17 #ifndef __VIDEO_ENCODER_AVC_H__
18 #define __VIDEO_ENCODER_AVC_H__
19 
20 #include "VideoEncoderBase.h"
21 
22 class VideoEncoderAVC : public VideoEncoderBase {
23 
24 public:
25     VideoEncoderAVC();
~VideoEncoderAVC()26     ~VideoEncoderAVC() {};
27 
28     virtual Encode_Status start();
29 
30     virtual Encode_Status derivedSetParams(VideoParamConfigSet *videoEncParams);
31     virtual Encode_Status derivedGetParams(VideoParamConfigSet *videoEncParams);
32     virtual Encode_Status derivedGetConfig(VideoParamConfigSet *videoEncConfig);
33     virtual Encode_Status derivedSetConfig(VideoParamConfigSet *videoEncConfig);
34 
35 protected:
36 
37     virtual Encode_Status sendEncodeCommand(EncodeTask *task);
38     virtual Encode_Status getExtFormatOutput(VideoEncOutputBuffer *outBuffer);
39     virtual Encode_Status updateFrameInfo(EncodeTask* task);
40 private:
41     // Local Methods
42 
43     Encode_Status getOneNALUnit(uint8_t *inBuffer, uint32_t bufSize, uint32_t *nalSize, uint32_t *nalType, uint32_t *nalOffset, uint32_t status);
44     Encode_Status getHeader(uint8_t *inBuffer, uint32_t bufSize, uint32_t *headerSize, uint32_t status);
45     Encode_Status outputCodecData(VideoEncOutputBuffer *outBuffer);
46     Encode_Status outputOneNALU(VideoEncOutputBuffer *outBuffer, bool startCode);
47     Encode_Status outputLengthPrefixed(VideoEncOutputBuffer *outBuffer);
48     Encode_Status outputNaluLengthsPrefixed(VideoEncOutputBuffer *outBuffer);
49 
50     Encode_Status renderMaxSliceSize();
51     Encode_Status renderAIR();
52     Encode_Status renderCIR();
53     Encode_Status renderSequenceParams(EncodeTask *task);
54     Encode_Status renderPictureParams(EncodeTask *task);
55     Encode_Status renderSliceParams(EncodeTask *task);
56     int calcLevel(int numMbs);
57     Encode_Status renderPackedSequenceParams(EncodeTask *task);
58     Encode_Status renderPackedPictureParams(EncodeTask *task);
59 
60 public:
61 
62     VideoParamsAVC mVideoParamsAVC;
63     uint32_t mSliceNum;
64     VABufferID packed_seq_header_param_buf_id;
65     VABufferID packed_seq_buf_id;
66     VABufferID packed_pic_header_param_buf_id;
67     VABufferID packed_pic_buf_id;
68     VABufferID packed_sei_header_param_buf_id;   /* the SEI buffer */
69     VABufferID packed_sei_buf_id;
70 
71 };
72 
73 #endif /* __VIDEO_ENCODER_AVC_H__ */
74