1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit 'f8a4d5e970f32f8cc747f9fa7bd975ee4a060ea1'

* commit 'f8a4d5e970f32f8cc747f9fa7bd975ee4a060ea1':
  h264_parser: K&R formatting cosmetics
  vorbis: return meaningful errors

Conflicts:
	libavcodec/h264_parser.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-06-08 10:50:24 +02:00
commit e2d4bcd7b8
2 changed files with 158 additions and 137 deletions

View File

@ -34,7 +34,8 @@
#include "internal.h"
static int h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_size)
static int h264_find_frame_end(H264Context *h, const uint8_t *buf,
int buf_size)
{
int i, j;
uint32_t state;
@ -65,27 +66,36 @@ static int h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_size)
if (state == 7) {
#if HAVE_FAST_UNALIGNED
/* we check i<buf_size instead of i+3/7 because its simpler
* and there should be FF_INPUT_BUFFER_PADDING_SIZE bytes at the end
/* we check i < buf_size instead of i + 3 / 7 because it is
* simpler and there must be FF_INPUT_BUFFER_PADDING_SIZE
* bytes at the end.
*/
# if HAVE_FAST_64BIT
while(i<next_avc && !((~*(const uint64_t*)(buf+i) & (*(const uint64_t*)(buf+i) - 0x0101010101010101ULL)) & 0x8080808080808080ULL))
while (i < next_avc &&
!((~*(const uint64_t *)(buf + i) &
(*(const uint64_t *)(buf + i) - 0x0101010101010101ULL)) &
0x8080808080808080ULL))
i += 8;
# else
while(i<next_avc && !((~*(const uint32_t*)(buf+i) & (*(const uint32_t*)(buf+i) - 0x01010101U)) & 0x80808080U))
while (i < next_avc &&
!((~*(const uint32_t *)(buf + i) &
(*(const uint32_t *)(buf + i) - 0x01010101U)) &
0x80808080U))
i += 4;
# endif
#endif
for(; i<next_avc; i++){
for (; i < next_avc; i++)
if (!buf[i]) {
state = 2;
break;
}
}
} else if (state <= 2) {
if(buf[i]==1) state^= 5; //2->7, 1->4, 0->5
else if(buf[i]) state = 7;
else state>>=1; //2->1, 1->0, 0->0
if (buf[i] == 1)
state ^= 5; // 2->7, 1->4, 0->5
else if (buf[i])
state = 7;
else
state >>= 1; // 2->1, 1->0, 0->0
} else if (state <= 5) {
int v = buf[i] & 0x1F;
if (v == 6 || v == 7 || v == 8 || v == 9) {
@ -227,16 +237,19 @@ static inline int parse_nal_units(AVCodecParserContext *s,
}
pps_id = get_ue_golomb(&h->gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(h->avctx, AV_LOG_ERROR, "pps_id out of range\n");
av_log(h->avctx, AV_LOG_ERROR,
"pps_id out of range\n");
return -1;
}
if (!h->pps_buffers[pps_id]) {
av_log(h->avctx, AV_LOG_ERROR, "non-existing PPS referenced\n");
av_log(h->avctx, AV_LOG_ERROR,
"non-existing PPS referenced\n");
return -1;
}
h->pps = *h->pps_buffers[pps_id];
if (!h->sps_buffers[h->pps.sps_id]) {
av_log(h->avctx, AV_LOG_ERROR, "non-existing SPS referenced\n");
av_log(h->avctx, AV_LOG_ERROR,
"non-existing SPS referenced\n");
return -1;
}
h->sps = *h->sps_buffers[h->pps.sps_id];
@ -260,14 +273,17 @@ static inline int parse_nal_units(AVCodecParserContext *s,
if (h->sps.poc_type == 0) {
h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
if (h->pps.pic_order_present == 1 &&
h->picture_structure == PICT_FRAME)
h->delta_poc_bottom = get_se_golomb(&h->gb);
}
if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) {
if (h->sps.poc_type == 1 &&
!h->sps.delta_pic_order_always_zero_flag) {
h->delta_poc[0] = get_se_golomb(&h->gb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
if (h->pps.pic_order_present == 1 &&
h->picture_structure == PICT_FRAME)
h->delta_poc[1] = get_se_golomb(&h->gb);
}
@ -416,11 +432,16 @@ static int h264_split(AVCodecContext *avctx,
for (i = 0; i <= buf_size; i++) {
if ((state & 0xFFFFFF1F) == 0x107)
has_sps = 1;
/* if((state&0xFFFFFF1F) == 0x101 || (state&0xFFFFFF1F) == 0x102 || (state&0xFFFFFF1F) == 0x105){
}*/
if((state&0xFFFFFF00) == 0x100 && (state&0xFFFFFF1F) != 0x107 && (state&0xFFFFFF1F) != 0x108 && (state&0xFFFFFF1F) != 0x109){
/* if ((state&0xFFFFFF1F) == 0x101 ||
* (state&0xFFFFFF1F) == 0x102 ||
* (state&0xFFFFFF1F) == 0x105) {
* }
*/
if ((state & 0xFFFFFF00) == 0x100 && (state & 0xFFFFFF1F) != 0x107 &&
(state & 0xFFFFFF1F) != 0x108 && (state & 0xFFFFFF1F) != 0x109) {
if (has_sps) {
while(i>4 && buf[i-5]==0) i--;
while (i > 4 && buf[i - 5] == 0)
i--;
return i - 4;
}
}

View File

@ -1386,7 +1386,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
if (max_output > ch_left * vlen) {
av_log(vc->avctx, AV_LOG_ERROR, "Insufficient output buffer\n");
return -1;
return AVERROR_INVALIDDATA;
}
av_dlog(NULL, " residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c);
@ -1637,7 +1637,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
residue = &vc->residues[mapping->submap_residue[i]];
if (ch_left < ch) {
av_log(vc->avctx, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n");
return -1;
return AVERROR_INVALIDDATA;
}
if (ch) {
ret = vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, vlen, ch_left);