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

Merge commit '1ce3ec24b35d9d549b12f17bd7fd391abaf3a6f7'

* commit '1ce3ec24b35d9d549b12f17bd7fd391abaf3a6f7':
  h263: K&R formatting cosmetics

Conflicts:
	libavcodec/h263dec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-10-23 19:26:59 +02:00
commit 4c18c31438

View File

@ -28,18 +28,18 @@
#define UNCHECKED_BITSTREAM_READER 1
#include "libavutil/cpu.h"
#include "internal.h"
#include "avcodec.h"
#include "error_resilience.h"
#include "mpegvideo.h"
#include "flv.h"
#include "h263.h"
#include "h263_parser.h"
#include "internal.h"
#include "mpeg4video.h"
#include "mpeg4video_parser.h"
#include "mpegvideo.h"
#include "msmpeg4.h"
#include "vdpau_internal.h"
#include "thread.h"
#include "flv.h"
#include "mpeg4video.h"
av_cold int ff_h263_decode_init(AVCodecContext *avctx)
{
@ -48,7 +48,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
s->out_format = FMT_H263;
s->width = avctx->coded_width;
s->height = avctx->coded_height;
s->workaround_bugs = avctx->workaround_bugs;
@ -117,7 +116,9 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
s->ehc_mode = 1;
/* for h263, we allocate the images after having read the header */
if (avctx->codec->id != AV_CODEC_ID_H263 && avctx->codec->id != AV_CODEC_ID_H263P && avctx->codec->id != AV_CODEC_ID_MPEG4)
if (avctx->codec->id != AV_CODEC_ID_H263 &&
avctx->codec->id != AV_CODEC_ID_H263P &&
avctx->codec->id != AV_CODEC_ID_MPEG4)
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
@ -137,32 +138,40 @@ av_cold int ff_h263_decode_end(AVCodecContext *avctx)
/**
* Return the number of bytes consumed for building the current frame.
*/
static int get_consumed_bytes(MpegEncContext *s, int buf_size){
static int get_consumed_bytes(MpegEncContext *s, int buf_size)
{
int pos = (get_bits_count(&s->gb) + 7) >> 3;
if (s->divx_packed || s->avctx->hwaccel) {
//we would have to scan through the whole buf to handle the weird reordering ...
/* We would have to scan through the whole buf to handle the weird
* reordering ... */
return buf_size;
} else if (s->flags & CODEC_FLAG_TRUNCATED) {
pos -= s->parse_context.last_index;
if(pos<0) pos=0; // padding is not really read so this might be -1
// padding is not really read so this might be -1
if (pos < 0)
pos = 0;
return pos;
} else {
if(pos==0) pos=1; //avoid infinite loops (i doubt that is needed but ...)
if(pos+10>buf_size) pos=buf_size; // oops ;)
// avoid infinite loops (maybe not needed...)
if (pos == 0)
pos = 1;
// oops ;)
if (pos + 10 > buf_size)
pos = buf_size;
return pos;
}
}
static int decode_slice(MpegEncContext *s){
static int decode_slice(MpegEncContext *s)
{
const int part_mask = s->partitioned_frame ? (ER_AC_END | ER_AC_ERROR) : 0x7F;
const int mb_size = 16 >> s->avctx->lowres;
int ret;
s->last_resync_gb = s->gb;
s->first_slice_line = 1;
s->resync_mb_x = s->mb_x;
s->resync_mb_y = s->mb_y;
@ -179,10 +188,9 @@ static int decode_slice(MpegEncContext *s){
if (s->partitioned_frame) {
const int qscale = s->qscale;
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4){
if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4)
if ((ret = ff_mpeg4_decode_partitions(s)) < 0)
return ret;
}
/* restore variables which were modified */
s->first_slice_line = 1;
@ -195,7 +203,8 @@ static int decode_slice(MpegEncContext *s){
/* per-row end of slice checks */
if (s->msmpeg4_version) {
if (s->resync_mb_y + s->slice_height == s->mb_y) {
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x - 1, s->mb_y, ER_MB_END);
return 0;
}
@ -213,9 +222,8 @@ static int decode_slice(MpegEncContext *s){
ff_update_block_index(s);
if(s->resync_mb_x == s->mb_x && s->resync_mb_y+1 == s->mb_y){
if (s->resync_mb_x == s->mb_x && s->resync_mb_y + 1 == s->mb_y)
s->first_slice_line = 0;
}
/* DCT & quantize */
@ -236,7 +244,8 @@ static int decode_slice(MpegEncContext *s){
if (s->loop_filter)
ff_h263_loop_filter(s);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x, s->mb_y, ER_MB_END & part_mask);
s->padding_bug_score--;
@ -248,12 +257,16 @@ static int decode_slice(MpegEncContext *s){
}
return 0;
} else if (ret == SLICE_NOEND) {
av_log(s->avctx, AV_LOG_ERROR, "Slice mismatch at MB: %d\n", xy);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, ER_MB_END&part_mask);
av_log(s->avctx, AV_LOG_ERROR,
"Slice mismatch at MB: %d\n", xy);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x + 1, s->mb_y,
ER_MB_END & part_mask);
return AVERROR_INVALIDDATA;
}
av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR&part_mask);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x, s->mb_y, ER_MB_ERROR & part_mask);
return AVERROR_INVALIDDATA;
}
@ -271,21 +284,20 @@ static int decode_slice(MpegEncContext *s){
av_assert1(s->mb_x == 0 && s->mb_y == s->mb_height);
if(s->codec_id==AV_CODEC_ID_MPEG4
&& (s->workaround_bugs&FF_BUG_AUTODETECT)
&& get_bits_left(&s->gb) >= 48
&& show_bits(&s->gb, 24)==0x4010
&& !s->data_partitioning)
if (s->codec_id == AV_CODEC_ID_MPEG4 &&
(s->workaround_bugs & FF_BUG_AUTODETECT) &&
get_bits_left(&s->gb) >= 48 &&
show_bits(&s->gb, 24) == 0x4010 &&
!s->data_partitioning)
s->padding_bug_score += 32;
/* try to detect the padding bug */
if( s->codec_id==AV_CODEC_ID_MPEG4
&& (s->workaround_bugs&FF_BUG_AUTODETECT)
&& get_bits_left(&s->gb) >=0
&& get_bits_left(&s->gb) < 137
// && !s->resync_marker
&& !s->data_partitioning){
if (s->codec_id == AV_CODEC_ID_MPEG4 &&
(s->workaround_bugs & FF_BUG_AUTODETECT) &&
get_bits_left(&s->gb) >= 0 &&
get_bits_left(&s->gb) < 137 &&
// !s->resync_marker &&
!s->data_partitioning) {
const int bits_count = get_bits_count(&s->gb);
const int bits_left = s->gb.size_in_bits - bits_count;
@ -297,7 +309,8 @@ static int decode_slice(MpegEncContext *s){
if (v == 0x7F && bits_left <= 8)
s->padding_bug_score--;
else if(v==0x7F && ((get_bits_count(&s->gb)+8)&8) && bits_left<=16)
else if (v == 0x7F && ((get_bits_count(&s->gb) + 8) & 8) &&
bits_left <= 16)
s->padding_bug_score += 4;
else
s->padding_bug_score++;
@ -305,7 +318,8 @@ static int decode_slice(MpegEncContext *s){
}
if (s->workaround_bugs & FF_BUG_AUTODETECT) {
if(s->padding_bug_score > -2 && !s->data_partitioning /*&& (s->divx_version>=0 || !s->resync_marker)*/)
if (s->padding_bug_score > -2 && !s->data_partitioning
/* && (s->divx_version >= 0 || !s->resync_marker) */)
s->workaround_bugs |= FF_BUG_NO_PADDING;
else
s->workaround_bugs &= ~FF_BUG_NO_PADDING;
@ -320,34 +334,38 @@ static int decode_slice(MpegEncContext *s){
if (s->msmpeg4_version && s->pict_type == AV_PICTURE_TYPE_I)
max_extra += 17;
/* buggy padding but the frame should still end approximately at the bitstream end */
if((s->workaround_bugs&FF_BUG_NO_PADDING) && (s->err_recognition&(AV_EF_BUFFER|AV_EF_AGGRESSIVE)))
/* buggy padding but the frame should still end approximately at
* the bitstream end */
if ((s->workaround_bugs & FF_BUG_NO_PADDING) &&
(s->err_recognition & (AV_EF_BUFFER|AV_EF_AGGRESSIVE)))
max_extra += 48;
else if ((s->workaround_bugs & FF_BUG_NO_PADDING))
max_extra += 256 * 256 * 256 * 64;
if(left>max_extra){
av_log(s->avctx, AV_LOG_ERROR, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24));
}
else if(left<0){
if (left > max_extra)
av_log(s->avctx, AV_LOG_ERROR,
"discarding %d junk bits at end, next would be %X\n",
left, show_bits(&s->gb, 24));
else if (left < 0)
av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
}else
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
else
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x - 1, s->mb_y, ER_MB_END);
return 0;
}
av_log(s->avctx, AV_LOG_ERROR, "slice end not reached but screenspace end (%d left %06X, score= %d)\n",
get_bits_left(&s->gb),
show_bits(&s->gb, 24), s->padding_bug_score);
av_log(s->avctx, AV_LOG_ERROR,
"slice end not reached but screenspace end (%d left %06X, score= %d)\n",
get_bits_left(&s->gb), show_bits(&s->gb, 24), s->padding_bug_score);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask);
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y,
ER_MB_END & part_mask);
return AVERROR_INVALIDDATA;
}
int ff_h263_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
@ -383,15 +401,16 @@ int ff_h263_decode_frame(AVCodecContext *avctx,
} else if (CONFIG_H263P_DECODER && s->codec_id == AV_CODEC_ID_H263P) {
next = ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
} else {
av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n");
av_log(s->avctx, AV_LOG_ERROR,
"this codec does not support truncated bitstreams\n");
return AVERROR(EINVAL);
}
if( ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )
if (ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf,
&buf_size) < 0)
return buf_size;
}
retry:
if (s->divx_packed && s->bitstream_buffer_size) {
int i;
@ -406,18 +425,18 @@ retry:
}
}
if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){ //divx 5.01+/xvid frame reorder
if (s->bitstream_buffer_size && (s->divx_packed || buf_size < 20)) // divx 5.01+/xvid frame reorder
ret = init_get_bits8(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size);
}else
else
ret = init_get_bits8(&s->gb, buf, buf_size);
s->bitstream_buffer_size = 0;
if (ret < 0)
return ret;
if (!s->context_initialized) {
if (!s->context_initialized)
if ((ret = ff_MPV_common_init(s)) < 0) // we need the idct permutaton for reading a custom matrix
return ret;
}
/* We need to set current_picture_ptr before reading the header,
* otherwise we cannot store anyting in there */
@ -457,7 +476,8 @@ retry:
s->height= avctx->coded_height;
}
}
if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size);
if (ret == FRAME_SKIPPED)
return get_consumed_bytes(s, buf_size);
/* skip if the header was thrashed */
if (ret < 0) {
@ -469,22 +489,24 @@ retry:
if (s->xvid_build == -1 && s->divx_version == -1 && s->lavc_build == -1) {
if (s->stream_codec_tag == AV_RL32("XVID") ||
s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") ||
s->codec_tag == AV_RL32("RMP4") || s->codec_tag == AV_RL32("ZMP4") ||
s->codec_tag == AV_RL32("SIPP")
)
s->codec_tag == AV_RL32("XVID") ||
s->codec_tag == AV_RL32("XVIX") ||
s->codec_tag == AV_RL32("RMP4") ||
s->codec_tag == AV_RL32("ZMP4") ||
s->codec_tag == AV_RL32("SIPP"))
s->xvid_build = 0;
#if 0
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==1
&& s->padding_bug_score > 0 && s->low_delay) // XVID with modified fourcc
if (s->codec_tag == AV_RL32("DIVX") && s->vo_type == 0 &&
s->vol_control_parameters == 1 &&
s->padding_bug_score > 0 && s->low_delay) // XVID with modified fourcc
s->xvid_build = 0;
#endif
}
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==0)
if (s->xvid_build == -1 && s->divx_version == -1 && s->lavc_build == -1)
if (s->codec_tag == AV_RL32("DIVX") && s->vo_type == 0 &&
s->vol_control_parameters == 0)
s->divx_version = 400; // divx 4
}
if (s->xvid_build >= 0 && s->divx_version >= 0) {
s->divx_version =
@ -495,17 +517,14 @@ retry:
if (s->codec_tag == AV_RL32("XVIX"))
s->workaround_bugs |= FF_BUG_XVID_ILACE;
if(s->codec_tag == AV_RL32("UMP4")){
if (s->codec_tag == AV_RL32("UMP4"))
s->workaround_bugs |= FF_BUG_UMP4;
}
if(s->divx_version>=500 && s->divx_build<1814){
if (s->divx_version >= 500 && s->divx_build < 1814)
s->workaround_bugs |= FF_BUG_QPEL_CHROMA;
}
if(s->divx_version>502 && s->divx_build<1814){
if (s->divx_version > 502 && s->divx_build < 1814)
s->workaround_bugs |= FF_BUG_QPEL_CHROMA2;
}
if (s->xvid_build <= 3U)
s->padding_bug_score = 256 * 256 * 256 * 64;
@ -530,9 +549,8 @@ retry:
if (s->lavc_build < 4655U)
s->workaround_bugs |= FF_BUG_DIRECT_BLOCKSIZE;
if(s->lavc_build<4670U){
if (s->lavc_build < 4670U)
s->workaround_bugs |= FF_BUG_EDGE;
}
if (s->lavc_build <= 4712U)
s->workaround_bugs |= FF_BUG_DC_CLIP;
@ -542,9 +560,8 @@ retry:
if (s->divx_version == 501 && s->divx_build == 20020416)
s->padding_bug_score = 256 * 256 * 256 * 64;
if(s->divx_version<500U){
if (s->divx_version < 500U)
s->workaround_bugs |= FF_BUG_EDGE;
}
if (s->divx_version >= 0)
s->workaround_bugs |= FF_BUG_HPEL_CHROMA;
@ -553,13 +570,14 @@ retry:
s->padding_bug_score = 256 * 256 * 256 * 64;
/* very ugly XVID padding bug detection FIXME/XXX solve this differently
* Let us hope this at least works.
*/
if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==-1
&& s->codec_id==AV_CODEC_ID_MPEG4 && s->vo_type==0)
* Let us hope this at least works. */
if (s->resync_marker == 0 && s->data_partitioning == 0 &&
s->divx_version == -1 && s->codec_id == AV_CODEC_ID_MPEG4 &&
s->vo_type == 0)
s->workaround_bugs |= FF_BUG_NO_PADDING;
if(s->lavc_build<4609U) //FIXME not sure about the version num but a 4609 file seems ok
// FIXME not sure about the version num but a 4609 file seems ok
if (s->lavc_build < 4609U)
s->workaround_bugs |= FF_BUG_NO_PADDING;
#endif
}
@ -581,23 +599,25 @@ retry:
}
if (avctx->debug & FF_DEBUG_BUGS)
av_log(s->avctx, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,
s->divx_packed ? "p" : "");
av_log(s->avctx, AV_LOG_DEBUG,
"bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
s->workaround_bugs, s->lavc_build, s->xvid_build,
s->divx_version, s->divx_build, s->divx_packed ? "p" : "");
#if HAVE_MMX
if (s->codec_id == AV_CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
if (s->codec_id == AV_CODEC_ID_MPEG4 && s->xvid_build >= 0 &&
avctx->idct_algo == FF_IDCT_AUTO &&
(av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
avctx->idct_algo = FF_IDCT_XVIDMMX;
ff_dct_common_init(s);
goto retry;
}
#endif
/* After H263 & mpeg4 header decode we have the height, width,*/
/* and other parameters. So then we could init the picture */
/* FIXME: By the way H263 decoder is evolving it should have */
/* an H263EncContext */
/* After H263 & mpeg4 header decode we have the height, width,
* and other parameters. So then we could init the picture.
* FIXME: By the way H263 decoder is evolving it should have
* an H263EncContext */
if (s->width != avctx->coded_width ||
s->height != avctx->coded_height ||
s->context_reinit) {
@ -610,7 +630,9 @@ retry:
return ret;
}
if((s->codec_id==AV_CODEC_ID_H263 || s->codec_id==AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_H263I))
if (s->codec_id == AV_CODEC_ID_H263 ||
s->codec_id == AV_CODEC_ID_H263P ||
s->codec_id == AV_CODEC_ID_H263I)
s->gob_index = ff_h263_get_gob_height(s);
// for skipping the frame
@ -621,9 +643,11 @@ retry:
if (s->last_picture_ptr == NULL &&
(s->pict_type == AV_PICTURE_TYPE_B || s->droppable))
return get_consumed_bytes(s, buf_size);
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
|| (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
|| avctx->skip_frame >= AVDISCARD_ALL)
if ((avctx->skip_frame >= AVDISCARD_NONREF &&
s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY &&
s->pict_type != AV_PICTURE_TYPE_I) ||
avctx->skip_frame >= AVDISCARD_ALL)
return get_consumed_bytes(s, buf_size);
if (s->next_p_frame_damaged) {
@ -652,19 +676,22 @@ retry:
goto frame_end;
}
if (avctx->hwaccel) {
if ((ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer, s->gb.buffer_end - s->gb.buffer)) < 0)
if (avctx->hwaccel)
if ((ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer,
s->gb.buffer_end - s->gb.buffer)) < 0)
return ret;
}
ff_mpeg_er_frame_start(s);
//the second part of the wmv2 header contains the MB skip bits which are stored in current_picture->mb_type
//which is not available before ff_MPV_frame_start()
/* the second part of the wmv2 header contains the MB skip bits which
* are stored in current_picture->mb_type which is not available before
* ff_MPV_frame_start() */
if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) {
ret = ff_wmv2_decode_secondary_picture_header(s);
if(ret<0) return ret;
if(ret==1) goto frame_end;
if (ret < 0)
return ret;
if (ret == 1)
goto frame_end;
}
/* decode each macroblock */
@ -674,7 +701,8 @@ retry:
ret = decode_slice(s);
while (s->mb_y < s->mb_height) {
if (s->msmpeg4_version) {
if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_left(&s->gb)<0)
if (s->slice_height == 0 || s->mb_x != 0 ||
(s->mb_y % s->slice_height) != 0 || get_bits_left(&s->gb) < 0)
break;
} else {
int prev_x = s->mb_x, prev_y = s->mb_y;
@ -687,22 +715,23 @@ retry:
if (s->msmpeg4_version < 4 && s->h263_pred)
ff_mpeg4_clean_buffers(s);
if (decode_slice(s) < 0) ret = AVERROR_INVALIDDATA;
if (decode_slice(s) < 0)
ret = AVERROR_INVALIDDATA;
}
if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)
if(!CONFIG_MSMPEG4_DECODER || ff_msmpeg4_decode_ext_header(s, buf_size) < 0){
if (s->msmpeg4_version && s->msmpeg4_version < 4 &&
s->pict_type == AV_PICTURE_TYPE_I)
if (!CONFIG_MSMPEG4_DECODER ||
ff_msmpeg4_decode_ext_header(s, buf_size) < 0)
s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR;
}
av_assert1(s->bitstream_buffer_size == 0);
frame_end:
ff_er_frame_end(&s->er);
if (avctx->hwaccel) {
if (avctx->hwaccel)
if ((ret = avctx->hwaccel->end_frame(avctx)) < 0)
return ret;
}
ff_MPV_frame_end(s);
@ -715,22 +744,25 @@ frame_end:
if (buf_size - current_pos > 7) {
int i;
for(i=current_pos; i<buf_size-4; i++){
if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){
for (i = current_pos; i < buf_size - 4; i++)
if (buf[i] == 0 &&
buf[i + 1] == 0 &&
buf[i + 2] == 1 &&
buf[i + 3] == 0xB6) {
startcode_found = !(buf[i + 4] & 0x40);
break;
}
}
}
if (startcode_found) {
av_fast_malloc(
&s->bitstream_buffer,
av_fast_malloc(&s->bitstream_buffer,
&s->allocated_bitstream_buffer_size,
buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE);
buf_size - current_pos +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->bitstream_buffer)
return AVERROR(ENOMEM);
memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
memcpy(s->bitstream_buffer, buf + current_pos,
buf_size - current_pos);
s->bitstream_buffer_size = buf_size - current_pos;
}
}
@ -771,7 +803,10 @@ frame_end:
*got_frame = 1;
}
return (ret && (avctx->err_recognition & AV_EF_EXPLODE))?ret:get_consumed_bytes(s, buf_size);
if (ret && (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
else
return get_consumed_bytes(s, buf_size);
}
const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[] = {