#include "libavutil/imgutils.h"
#include "internal.h"
+#include "cabac.h"
+#include "cabac_functions.h"
#include "dsputil.h"
#include "avcodec.h"
#include "mpegvideo.h"
#include "vdpau_internal.h"
#include "libavutil/avassert.h"
-#include "cabac.h"
-
//#undef NDEBUG
#include <assert.h>
MpegEncContext * const s = &h->s;
int i;
const int pixel_shift = h->pixel_shift;
- int thread_count = (s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1;
if(MPV_frame_start(s, s->avctx) < 0)
return -1;
/* can't be in alloc_tables because linesize isn't known there.
* FIXME: redo bipred weight to not require extra buffer? */
- for(i = 0; i < thread_count; i++)
+ for(i = 0; i < s->slice_context_count; i++)
if(h->thread_context[i] && !h->thread_context[i]->s.obmc_scratchpad)
h->thread_context[i]->s.obmc_scratchpad = av_malloc(16*6*s->linesize);
idct_dc_add(ptr, h->mb + (i*16+p*256 << pixel_shift), linesize);
else
idct_add (ptr, h->mb + (i*16+p*256 << pixel_shift), linesize);
- }else
+ } else if (CONFIG_SVQ3_DECODER)
ff_svq3_add_idct_c(ptr, h->mb + i*16+p*256, linesize, qscale, 0);
}
}
dctcoef_set(h->mb+(p*256 << pixel_shift), pixel_shift, dc_mapping[i], dctcoef_get(h->mb_luma_dc[p], pixel_shift, i));
}
}
- }else
+ } else if (CONFIG_SVQ3_DECODER)
ff_svq3_luma_dc_dequant_idct_c(h->mb+p*256, h->mb_luma_dc[p], qscale);
}
}
}
}
}
- }else{
+ } else if (CONFIG_SVQ3_DECODER) {
for(i=0; i<16; i++){
if(h->non_zero_count_cache[ scan8[i+p*16] ] || h->mb[i*16+p*256]){ //FIXME benchmark weird rule, & below
uint8_t * const ptr= dest_y + block_offset[i];
h->h264dsp.h264_idct_add8(dest, block_offset,
h->mb, uvlinesize,
h->non_zero_count_cache);
- }else{
+ } else if (CONFIG_SVQ3_DECODER) {
h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16*1, h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16*2, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
for(j=1; j<3; j++){
return -1;
}
} else {
- for(i = 1; i < s->avctx->thread_count; i++) {
+ for(i = 1; i < s->slice_context_count; i++) {
H264Context *c;
c = h->thread_context[i] = av_malloc(sizeof(H264Context));
memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext));
clone_tables(c, h, i);
}
- for(i = 0; i < s->avctx->thread_count; i++)
+ for(i = 0; i < s->slice_context_count; i++)
if (context_init(h->thread_context[i]) < 0) {
av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed.\n");
return -1;
int nals_needed=0; ///< number of NALs that need decoding before the next frame thread starts
int nal_index;
- h->max_contexts = (HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_SLICE)) ? avctx->thread_count : 1;
+ h->max_contexts = s->slice_context_count;
if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){
h->current_slice = 0;
if (!s->first_field)
int consumed;
int dst_length;
int bit_length;
- const uint8_t *ptr;
+ uint8_t *ptr;
int i, nalsize = 0;
int err;
if(buf_index >= next_avc) {
- if(buf_index >= buf_size) break;
+ if (buf_index >= buf_size - h->nal_length_size) break;
nalsize = 0;
for(i = 0; i < h->nal_length_size; i++)
nalsize = (nalsize << 8) | buf[buf_index++];
}
if (h->is_avc && (nalsize != consumed) && nalsize){
+ // set trailing bits in the last partial byte to zero
+ if (bit_length & 7)
+ ptr[bit_length >> 3] = ptr[bit_length >> 3] & (0xff << 8 - (bit_length & 7));
av_log(h->s.avctx, AV_LOG_DEBUG, "AVC: Consumed only %d bytes instead of %d\n", consumed, nalsize);
}
H264Context *h = avctx->priv_data;
MpegEncContext *s = &h->s;
AVFrame *pict = data;
- int buf_index;
+ int buf_index = 0;
s->flags= avctx->flags;
s->flags2= avctx->flags2;
*pict= *(AVFrame*)out;
}
- return 0;
+ return buf_index;
}
buf_index=decode_nal_units(h, buf, buf_size);
uint8_t temp[SIZE];
PutBitContext pb;
GetBitContext gb;
-// int int_temp[10000];
DSPContext dsp;
AVCodecContext avctx;
+ avctx.av_class = avcodec_get_class();
dsputil_init(&dsp, &avctx);
init_put_bits(&pb, temp, SIZE);
init_get_bits(&gb, temp, 8*SIZE);
for(i=0; i<COUNT; i++){
- int j, s;
-
- s= show_bits(&gb, 24);
+ int j, s = show_bits(&gb, 24);
START_TIMER
j= get_ue_golomb(&gb);
init_get_bits(&gb, temp, 8*SIZE);
for(i=0; i<COUNT; i++){
- int j, s;
-
- s= show_bits(&gb, 24);
+ int j, s = show_bits(&gb, 24);
START_TIMER
j= get_se_golomb(&gb);