You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	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
This commit is contained in:
		
				
					committed by
					
						 Carl Eugen Hoyos
						Carl Eugen Hoyos
					
				
			
			
				
	
			
			
			
						parent
						
							20a93972c4
						
					
				
				
					commit
					1790a5e908
				
			| @@ -1359,14 +1359,7 @@ static inline void write_back_motion(H264Context *h, int mb_type){ | ||||
|     } | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * 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){ | ||||
| const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length){ | ||||
|     int i, si, di; | ||||
|     uint8_t *dst; | ||||
|     int bufidx; | ||||
| @@ -1456,11 +1449,7 @@ nsc: | ||||
|     return dst; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * 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 ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src){ | ||||
|     int v= *src; | ||||
|     int r; | ||||
|  | ||||
| @@ -6897,7 +6886,7 @@ static int decode_buffering_period(H264Context *h){ | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| static int decode_sei(H264Context *h){ | ||||
| int ff_h264_decode_sei(H264Context *h){ | ||||
|     MpegEncContext * const s = &h->s; | ||||
|  | ||||
|     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 | ||||
|     } | ||||
| } | ||||
|  | ||||
| static inline int decode_seq_parameter_set(H264Context *h){ | ||||
| int ff_h264_decode_seq_parameter_set(H264Context *h){ | ||||
|     MpegEncContext * const s = &h->s; | ||||
|     int profile_idc, level_idc; | ||||
|     unsigned int sps_id; | ||||
| @@ -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)]; | ||||
| } | ||||
|  | ||||
| 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; | ||||
|     unsigned int pps_id= get_ue_golomb(&s->gb); | ||||
|     PPS *pps; | ||||
| @@ -7449,13 +7438,13 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ | ||||
|  | ||||
|         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){ | ||||
|             return -1; | ||||
|         } | ||||
|         while(ptr[dst_length - 1] == 0 && dst_length > 0) | ||||
|             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){ | ||||
|             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){ | ||||
|             break; | ||||
|         case NAL_SEI: | ||||
|             init_get_bits(&s->gb, ptr, bit_length); | ||||
|             decode_sei(h); | ||||
|             ff_h264_decode_sei(h); | ||||
|             break; | ||||
|         case NAL_SPS: | ||||
|             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) | ||||
|                 s->low_delay=1; | ||||
| @@ -7552,7 +7541,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ | ||||
|         case NAL_PPS: | ||||
|             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; | ||||
|         case NAL_AUD: | ||||
| @@ -8039,7 +8028,7 @@ int main(void){ | ||||
|             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") | ||||
|  | ||||
|   | ||||
| @@ -532,4 +532,34 @@ typedef struct H264Context{ | ||||
|     int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs | ||||
| }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 */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user