Commit 1790a5e9 authored by Ivan Schreter's avatar Ivan Schreter Committed by Carl Eugen Hoyos

Make the following H264 functions available to the parser:

ff_h264_decode_sei, ff_h264_decode_seq_parameter_set,
ff_h264_decode_picture_parameter_set, ff_h264_decode_nal,
ff_h264_decode_rbsp_trailing

Patch by Ivan Schreter, schreter gmx net

Originally committed as revision 17487 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 20a93972
...@@ -1359,14 +1359,7 @@ static inline void write_back_motion(H264Context *h, int mb_type){ ...@@ -1359,14 +1359,7 @@ static inline void write_back_motion(H264Context *h, int mb_type){
} }
} }
/** const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length){
* Decodes a network abstraction layer unit.
* @param consumed is the number of bytes used as input
* @param length is the length of the array
* @param dst_length is the number of decoded bytes FIXME here or a decode rbsp tailing?
* @returns decoded bytes, might be src+1 if no escapes
*/
static const uint8_t *decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length){
int i, si, di; int i, si, di;
uint8_t *dst; uint8_t *dst;
int bufidx; int bufidx;
...@@ -1456,11 +1449,7 @@ nsc: ...@@ -1456,11 +1449,7 @@ nsc:
return dst; return dst;
} }
/** int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src){
* identifies the exact end of the bitstream
* @return the length of the trailing, or 0 if damaged
*/
static int decode_rbsp_trailing(H264Context *h, const uint8_t *src){
int v= *src; int v= *src;
int r; int r;
...@@ -6897,7 +6886,7 @@ static int decode_buffering_period(H264Context *h){ ...@@ -6897,7 +6886,7 @@ static int decode_buffering_period(H264Context *h){
return 0; return 0;
} }
static int decode_sei(H264Context *h){ int ff_h264_decode_sei(H264Context *h){
MpegEncContext * const s = &h->s; MpegEncContext * const s = &h->s;
while(get_bits_count(&s->gb) + 16 < s->gb.size_in_bits){ while(get_bits_count(&s->gb) + 16 < s->gb.size_in_bits){
...@@ -7091,7 +7080,7 @@ static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_s ...@@ -7091,7 +7080,7 @@ static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_s
} }
} }
static inline int decode_seq_parameter_set(H264Context *h){ int ff_h264_decode_seq_parameter_set(H264Context *h){
MpegEncContext * const s = &h->s; MpegEncContext * const s = &h->s;
int profile_idc, level_idc; int profile_idc, level_idc;
unsigned int sps_id; unsigned int sps_id;
...@@ -7238,7 +7227,7 @@ build_qp_table(PPS *pps, int t, int index) ...@@ -7238,7 +7227,7 @@ build_qp_table(PPS *pps, int t, int index)
pps->chroma_qp_table[t][i] = chroma_qp[av_clip(i + index, 0, 51)]; pps->chroma_qp_table[t][i] = chroma_qp[av_clip(i + index, 0, 51)];
} }
static inline int decode_picture_parameter_set(H264Context *h, int bit_length){ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
MpegEncContext * const s = &h->s; MpegEncContext * const s = &h->s;
unsigned int pps_id= get_ue_golomb(&s->gb); unsigned int pps_id= get_ue_golomb(&s->gb);
PPS *pps; PPS *pps;
...@@ -7449,13 +7438,13 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ ...@@ -7449,13 +7438,13 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
hx = h->thread_context[context_count]; hx = h->thread_context[context_count];
ptr= decode_nal(hx, buf + buf_index, &dst_length, &consumed, h->is_avc ? nalsize : buf_size - buf_index); ptr= ff_h264_decode_nal(hx, buf + buf_index, &dst_length, &consumed, h->is_avc ? nalsize : buf_size - buf_index);
if (ptr==NULL || dst_length < 0){ if (ptr==NULL || dst_length < 0){
return -1; return -1;
} }
while(ptr[dst_length - 1] == 0 && dst_length > 0) while(ptr[dst_length - 1] == 0 && dst_length > 0)
dst_length--; dst_length--;
bit_length= !dst_length ? 0 : (8*dst_length - decode_rbsp_trailing(h, ptr + dst_length - 1)); bit_length= !dst_length ? 0 : (8*dst_length - ff_h264_decode_rbsp_trailing(h, ptr + dst_length - 1));
if(s->avctx->debug&FF_DEBUG_STARTCODE){ if(s->avctx->debug&FF_DEBUG_STARTCODE){
av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", hx->nal_unit_type, buf_index, buf_size, dst_length); av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", hx->nal_unit_type, buf_index, buf_size, dst_length);
...@@ -7537,11 +7526,11 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ ...@@ -7537,11 +7526,11 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
break; break;
case NAL_SEI: case NAL_SEI:
init_get_bits(&s->gb, ptr, bit_length); init_get_bits(&s->gb, ptr, bit_length);
decode_sei(h); ff_h264_decode_sei(h);
break; break;
case NAL_SPS: case NAL_SPS:
init_get_bits(&s->gb, ptr, bit_length); init_get_bits(&s->gb, ptr, bit_length);
decode_seq_parameter_set(h); ff_h264_decode_seq_parameter_set(h);
if(s->flags& CODEC_FLAG_LOW_DELAY) if(s->flags& CODEC_FLAG_LOW_DELAY)
s->low_delay=1; s->low_delay=1;
...@@ -7552,7 +7541,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ ...@@ -7552,7 +7541,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
case NAL_PPS: case NAL_PPS:
init_get_bits(&s->gb, ptr, bit_length); init_get_bits(&s->gb, ptr, bit_length);
decode_picture_parameter_set(h, bit_length); ff_h264_decode_picture_parameter_set(h, bit_length);
break; break;
case NAL_AUD: case NAL_AUD:
...@@ -8039,7 +8028,7 @@ int main(void){ ...@@ -8039,7 +8028,7 @@ int main(void){
return -1; return -1;
} }
out= decode_nal(&h, nal, &out_length, &consumed, nal_length); out= ff_h264_decode_nal(&h, nal, &out_length, &consumed, nal_length);
STOP_TIMER("NAL") STOP_TIMER("NAL")
......
...@@ -532,4 +532,34 @@ typedef struct H264Context{ ...@@ -532,4 +532,34 @@ typedef struct H264Context{
int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
}H264Context; }H264Context;
/**
* Decode SEI
*/
int ff_h264_decode_sei(H264Context *h);
/**
* Decode SPS
*/
int ff_h264_decode_seq_parameter_set(H264Context *h);
/**
* Decode PPS
*/
int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length);
/**
* Decodes a network abstraction layer unit.
* @param consumed is the number of bytes used as input
* @param length is the length of the array
* @param dst_length is the number of decoded bytes FIXME here or a decode rbsp tailing?
* @returns decoded bytes, might be src+1 if no escapes
*/
const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length);
/**
* identifies the exact end of the bitstream
* @return the length of the trailing, or 0 if damaged
*/
int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src);
#endif /* AVCODEC_H264_H */ #endif /* AVCODEC_H264_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment