Commit 5bf2ac2b authored by Luca Barbato's avatar Luca Barbato

error_resilience: use the ER_ namespace

Add the namespace to {AC_,DC_,MV_}{END,ERROR} macros
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent 878dda5d
This diff is collapsed.
......@@ -148,7 +148,7 @@ static int get_consumed_bytes(MpegEncContext *s, int buf_size){
}
static int decode_slice(MpegEncContext *s){
const int part_mask= s->partitioned_frame ? (AC_END|AC_ERROR) : 0x7F;
const int part_mask= s->partitioned_frame ? (ER_AC_END|ER_AC_ERROR) : 0x7F;
const int mb_size= 16>>s->avctx->lowres;
s->last_resync_gb= s->gb;
s->first_slice_line= 1;
......@@ -184,7 +184,7 @@ 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, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_AC_END|ER_DC_END|ER_MV_END);
return 0;
}
......@@ -225,7 +225,7 @@ static int decode_slice(MpegEncContext *s){
ff_h263_loop_filter(s);
//printf("%d %d %d %06X\n", s->mb_x, s->mb_y, s->gb.size*8 - get_bits_count(&s->gb), show_bits(&s->gb, 24));
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END)&part_mask);
s->padding_bug_score--;
......@@ -238,11 +238,11 @@ 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, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END)&part_mask);
return -1;
}
av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR)&part_mask);
return -1;
}
......@@ -321,7 +321,7 @@ static int decode_slice(MpegEncContext *s){
else if(left<0){
av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
}else
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_AC_END|ER_DC_END|ER_MV_END);
return 0;
}
......@@ -330,7 +330,7 @@ static int decode_slice(MpegEncContext *s){
get_bits_left(&s->gb),
show_bits(&s->gb, 24), s->padding_bug_score);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END)&part_mask);
return -1;
}
......@@ -661,7 +661,7 @@ retry:
if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)
if(!CONFIG_MSMPEG4_DECODER || msmpeg4_decode_ext_header(s, buf_size) < 0){
s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR;
s->error_status_table[s->mb_num-1]= ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR;
}
assert(s->bitstream_buffer_size==0);
......
......@@ -3556,7 +3556,7 @@ static void decode_finish_row(H264Context *h){
static int decode_slice(struct AVCodecContext *avctx, void *arg){
H264Context *h = *(void**)arg;
MpegEncContext * const s = &h->s;
const int part_mask= s->partitioned_frame ? (AC_END|AC_ERROR) : 0x7F;
const int part_mask= s->partitioned_frame ? (ER_AC_END|ER_AC_ERROR) : 0x7F;
int lf_x_start = s->mb_x;
s->mb_skip_run= -1;
......@@ -3595,13 +3595,13 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
eos = get_cabac_terminate( &h->cabac );
if((s->workaround_bugs & FF_BUG_TRUNCATED) && h->cabac.bytestream > h->cabac.bytestream_end + 2){
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END)&part_mask);
if (s->mb_x >= lf_x_start) loop_filter(h, lf_x_start, s->mb_x + 1);
return 0;
}
if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) {
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d, bytestream (%td)\n", s->mb_x, s->mb_y, h->cabac.bytestream_end - h->cabac.bytestream);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR)&part_mask);
return -1;
}
......@@ -3619,7 +3619,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
if( eos || s->mb_y >= s->mb_height ) {
tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END)&part_mask);
if (s->mb_x > lf_x_start) loop_filter(h, lf_x_start, s->mb_x);
return 0;
}
......@@ -3641,7 +3641,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
if(ret<0){
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR)&part_mask);
return -1;
}
......@@ -3659,11 +3659,11 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
if(get_bits_count(&s->gb) == s->gb.size_in_bits ) {
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END)&part_mask);
return 0;
}else{
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END)&part_mask);
return -1;
}
......@@ -3673,12 +3673,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
if(get_bits_count(&s->gb) >= s->gb.size_in_bits && s->mb_skip_run<=0){
tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
if(get_bits_count(&s->gb) == s->gb.size_in_bits ){
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END)&part_mask);
if (s->mb_x > lf_x_start) loop_filter(h, lf_x_start, s->mb_x);
return 0;
}else{
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR)&part_mask);
return -1;
}
......
......@@ -668,13 +668,13 @@ av_cold void ff_h264_decode_init_vlc(void);
/**
* Decode a macroblock
* @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
* @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed
*/
int ff_h264_decode_mb_cavlc(H264Context *h);
/**
* Decode a CABAC coded macroblock
* @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
* @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed
*/
int ff_h264_decode_mb_cabac(H264Context *h);
......
......@@ -1863,7 +1863,7 @@ static av_always_inline void decode_cabac_luma_residual( H264Context *h, const u
/**
* Decode a macroblock.
* @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
* @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed
*/
int ff_h264_decode_mb_cabac(H264Context *h) {
MpegEncContext * const s = &h->s;
......
......@@ -784,6 +784,6 @@ int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_of
error:
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y,
(s->mb_x>>1)-1, (s->mb_y>>1)-1,
(AC_END|DC_END|MV_END) );
(ER_AC_END|ER_DC_END|ER_MV_END) );
return 0;
}
......@@ -1866,9 +1866,9 @@ static int slice_decode_thread(AVCodecContext *c, void *arg)
if (c->err_recognition & AV_EF_EXPLODE)
return ret;
if (s->resync_mb_x >= 0 && s->resync_mb_y >= 0)
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, AC_ERROR | DC_ERROR | MV_ERROR);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
} else {
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END | DC_END | MV_END);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_AC_END | ER_DC_END | ER_MV_END);
}
if (s->mb_y == s->end_mb_y)
......@@ -2450,9 +2450,9 @@ static int decode_chunks(AVCodecContext *avctx,
if (avctx->err_recognition & AV_EF_EXPLODE)
return ret;
if (s2->resync_mb_x >= 0 && s2->resync_mb_y >= 0)
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR | DC_ERROR | MV_ERROR);
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
} else {
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, AC_END | DC_END | MV_END);
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, ER_AC_END | ER_DC_END | ER_MV_END);
}
}
}
......
......@@ -790,8 +790,8 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
int ff_mpeg4_decode_partitions(MpegEncContext *s)
{
int mb_num;
const int part_a_error= s->pict_type==AV_PICTURE_TYPE_I ? (DC_ERROR|MV_ERROR) : MV_ERROR;
const int part_a_end = s->pict_type==AV_PICTURE_TYPE_I ? (DC_END |MV_END) : MV_END;
const int part_a_error= s->pict_type==AV_PICTURE_TYPE_I ? (ER_DC_ERROR|ER_MV_ERROR) : ER_MV_ERROR;
const int part_a_end = s->pict_type==AV_PICTURE_TYPE_I ? (ER_DC_END |ER_MV_END) : ER_MV_END;
mb_num= mpeg4_decode_partition_a(s);
if(mb_num<0){
......@@ -826,11 +826,11 @@ int ff_mpeg4_decode_partitions(MpegEncContext *s)
if( mpeg4_decode_partition_b(s, mb_num) < 0){
if(s->pict_type==AV_PICTURE_TYPE_P)
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, DC_ERROR);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_DC_ERROR);
return -1;
}else{
if(s->pict_type==AV_PICTURE_TYPE_P)
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, DC_END);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_DC_END);
}
return 0;
......
......@@ -474,13 +474,12 @@ typedef struct MpegEncContext {
int error_count, error_occurred;
uint8_t *error_status_table; ///< table of the error status of each MB
#define VP_START 1 ///< current MB is the first after a resync marker
#define AC_ERROR 2
#define DC_ERROR 4
#define MV_ERROR 8
#define AC_END 16
#define DC_END 32
#define MV_END 64
//FIXME some prefix?
#define ER_AC_ERROR 2
#define ER_DC_ERROR 4
#define ER_MV_ERROR 8
#define ER_AC_END 16
#define ER_DC_END 32
#define ER_MV_END 64
int resync_mb_x; ///< x position of last resync marker
int resync_mb_y; ///< y position of last resync marker
......
......@@ -609,7 +609,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
if(ret == SLICE_END) break;
}
ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_AC_END|ER_DC_END|ER_MV_END);
return s->gb.size_in_bits;
}
......
......@@ -1278,7 +1278,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
s->dsp.clear_blocks(s->block[0]);
if(rv34_decode_macroblock(r, r->intra_types + s->mb_x * 4 + 4) < 0){
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR);
return -1;
}
if (++s->mb_x == s->mb_width) {
......@@ -1296,7 +1296,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
s->first_slice_line=0;
s->mb_num_left--;
}
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_AC_END|ER_DC_END|ER_MV_END);
return s->mb_y == s->mb_height;
}
......
......@@ -4548,7 +4548,7 @@ static void vc1_decode_i_blocks(VC1Context *v)
if (v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq);
if (get_bits_count(&s->gb) > v->bits) {
ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END));
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
get_bits_count(&s->gb), v->bits);
return;
......@@ -4563,7 +4563,7 @@ static void vc1_decode_i_blocks(VC1Context *v)
}
if (v->s.loop_filter)
ff_draw_horiz_band(s, (s->mb_height - 1) * 16, 16);
ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (ER_AC_END|ER_DC_END|ER_MV_END));
}
/** Decode blocks of I-frame for advanced profile
......@@ -4673,7 +4673,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
if (get_bits_count(&s->gb) > v->bits) {
// TODO: may need modification to handle slice coding
ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END));
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
get_bits_count(&s->gb), v->bits);
return;
......@@ -4698,7 +4698,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
if (v->s.loop_filter)
ff_draw_horiz_band(s, (s->end_mb_y-1)*16, 16);
ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
(s->end_mb_y << v->field_mode) - 1, (AC_END|DC_END|MV_END));
(s->end_mb_y << v->field_mode) - 1, (ER_AC_END|ER_DC_END|ER_MV_END));
}
static void vc1_decode_p_blocks(VC1Context *v)
......@@ -4749,7 +4749,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
vc1_apply_p_loop_filter(v);
if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
// TODO: may need modification to handle slice coding
ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END));
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y);
return;
......@@ -4773,7 +4773,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
if (s->end_mb_y >= s->start_mb_y)
ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
(s->end_mb_y << v->field_mode) - 1, (AC_END|DC_END|MV_END));
(s->end_mb_y << v->field_mode) - 1, (ER_AC_END|ER_DC_END|ER_MV_END));
}
static void vc1_decode_b_blocks(VC1Context *v)
......@@ -4818,7 +4818,7 @@ static void vc1_decode_b_blocks(VC1Context *v)
vc1_decode_b_mb(v);
if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
// TODO: may need modification to handle slice coding
ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (ER_AC_END|ER_DC_END|ER_MV_END));
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y);
return;
......@@ -4834,14 +4834,14 @@ static void vc1_decode_b_blocks(VC1Context *v)
if (v->s.loop_filter)
ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
(s->end_mb_y << v->field_mode) - 1, (AC_END|DC_END|MV_END));
(s->end_mb_y << v->field_mode) - 1, (ER_AC_END|ER_DC_END|ER_MV_END));
}
static void vc1_decode_skip_blocks(VC1Context *v)
{
MpegEncContext *s = &v->s;
ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, (AC_END|DC_END|MV_END));
ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, (ER_AC_END|ER_DC_END|ER_MV_END));
s->first_slice_line = 1;
for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
s->mb_x = 0;
......
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