*/
/**
- * @file h264.c
+ * @file libavcodec/h264.c
* H.264 / AVC / MPEG4 part10 codec.
* @author Michael Niedermayer <michaelni@gmx.at>
*/
#include "h264data.h"
#include "h264_parser.h"
#include "golomb.h"
+#include "mathops.h"
#include "rectangle.h"
#include "vdpau_internal.h"
if(avctx->codec_id == CODEC_ID_SVQ3)
avctx->pix_fmt= PIX_FMT_YUVJ420P;
- else if(avctx->codec_id == CODEC_ID_H264_VDPAU)
+ else if(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
avctx->pix_fmt= PIX_FMT_VDPAU_H264;
else
avctx->pix_fmt= PIX_FMT_YUV420P;
const int mb_type= s->current_picture.mb_type[mb_xy];
int is_complex = CONFIG_SMALL || h->is_complex || IS_INTRA_PCM(mb_type) || s->qscale == 0;
- if(CONFIG_H264_ENCODER && !s->decode)
- return;
-
if (is_complex)
hl_decode_mb_complex(h);
else hl_decode_mb_simple(h);
chroma_def = 1<<h->chroma_log2_weight_denom;
for(list=0; list<2; list++){
+ h->luma_weight_flag[list] = 0;
+ h->chroma_weight_flag[list] = 0;
for(i=0; i<h->ref_count[list]; i++){
int luma_weight_flag, chroma_weight_flag;
h->luma_weight[list][i]= get_se_golomb(&s->gb);
h->luma_offset[list][i]= get_se_golomb(&s->gb);
if( h->luma_weight[list][i] != luma_def
- || h->luma_offset[list][i] != 0)
+ || h->luma_offset[list][i] != 0) {
h->use_weight= 1;
+ h->luma_weight_flag[list]= 1;
+ }
}else{
h->luma_weight[list][i]= luma_def;
h->luma_offset[list][i]= 0;
h->chroma_weight[list][i][j]= get_se_golomb(&s->gb);
h->chroma_offset[list][i][j]= get_se_golomb(&s->gb);
if( h->chroma_weight[list][i][j] != chroma_def
- || h->chroma_offset[list][i][j] != 0)
+ || h->chroma_offset[list][i][j] != 0) {
h->use_weight_chroma= 1;
+ h->chroma_weight_flag[list]= 1;
+ }
}
}else{
int j;
static void implicit_weight_table(H264Context *h){
MpegEncContext * const s = &h->s;
- int ref0, ref1;
+ int ref0, ref1, i;
int cur_poc = s->current_picture_ptr->poc;
if( h->ref_count[0] == 1 && h->ref_count[1] == 1
h->use_weight_chroma= 2;
h->luma_log2_weight_denom= 5;
h->chroma_log2_weight_denom= 5;
+ for (i = 0; i < 2; i++) {
+ h->luma_weight_flag[i] = 0;
+ h->chroma_weight_flag[i] = 0;
+ }
for(ref0=0; ref0 < h->ref_count[0]; ref0++){
int poc0 = h->ref_list[0][ref0].poc;
}
}
if(s->dsp.h264_idct8_add == ff_h264_idct8_add_c){
- memcpy(h->zigzag_scan8x8, zigzag_scan8x8, 64*sizeof(uint8_t));
+ memcpy(h->zigzag_scan8x8, ff_zigzag_direct, 64*sizeof(uint8_t));
memcpy(h->zigzag_scan8x8_cavlc, zigzag_scan8x8_cavlc, 64*sizeof(uint8_t));
memcpy(h->field_scan8x8, field_scan8x8, 64*sizeof(uint8_t));
memcpy(h->field_scan8x8_cavlc, field_scan8x8_cavlc, 64*sizeof(uint8_t));
}else{
for(i=0; i<64; i++){
#define T(x) (x>>3) | ((x&7)<<3)
- h->zigzag_scan8x8[i] = T(zigzag_scan8x8[i]);
+ h->zigzag_scan8x8[i] = T(ff_zigzag_direct[i]);
h->zigzag_scan8x8_cavlc[i] = T(zigzag_scan8x8_cavlc[i]);
h->field_scan8x8[i] = T(field_scan8x8[i]);
h->field_scan8x8_cavlc[i] = T(field_scan8x8_cavlc[i]);
}
if(h->sps.transform_bypass){ //FIXME same ugly
h->zigzag_scan_q0 = zigzag_scan;
- h->zigzag_scan8x8_q0 = zigzag_scan8x8;
+ h->zigzag_scan8x8_q0 = ff_zigzag_direct;
h->zigzag_scan8x8_cavlc_q0 = zigzag_scan8x8_cavlc;
h->field_scan_q0 = field_scan;
h->field_scan8x8_q0 = field_scan8x8;
pred_weight_table(h);
else if(h->pps.weighted_bipred_idc==2 && h->slice_type_nos== FF_B_TYPE)
implicit_weight_table(h);
- else
+ else {
h->use_weight = 0;
+ for (i = 0; i < 2; i++) {
+ h->luma_weight_flag[i] = 0;
+ h->chroma_weight_flag[i] = 0;
+ }
+ }
if(h->nal_ref_idc)
decode_ref_pic_marking(h0, &s->gb);
const int mb_type = s->current_picture.mb_type[mb_xy];
const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
int first_vertical_edge_done = 0;
- int dir;
+ av_unused int dir;
//for sufficiently low qp, filtering wouldn't do anything
//this is a conservative estimate: could also check beta_offset and more accurate chroma_qp
s->mb_skip_run= -1;
h->is_complex = FRAME_MBAFF || s->picture_structure != PICT_FRAME || s->codec_id != CODEC_ID_H264 ||
- (CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)) || (CONFIG_H264_ENCODER && s->encoding);
+ (CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
if( h->pps.cabac ) {
int i;
}while(get_bits(&s->gb, 8) == 255);
switch(type){
- case 1: // Picture timing SEI
+ case SEI_TYPE_PIC_TIMING: // Picture timing SEI
if(decode_picture_timing(h) < 0)
return -1;
break;
- case 5:
+ case SEI_TYPE_USER_DATA_UNREGISTERED:
if(decode_unregistered_user_data(h, size) < 0)
return -1;
break;
const uint8_t *jvt_list, const uint8_t *fallback_list){
MpegEncContext * const s = &h->s;
int i, last = 8, next = 8;
- const uint8_t *scan = size == 16 ? zigzag_scan : zigzag_scan8x8;
+ const uint8_t *scan = size == 16 ? zigzag_scan : ff_zigzag_direct;
if(!get_bits1(&s->gb)) /* matrix not written, we use the predicted one */
memcpy(factors, fallback_list, size*sizeof(uint8_t));
else
if(sps->profile_idc >= 100){ //high profile
sps->chroma_format_idc= get_ue_golomb_31(&s->gb);
if(sps->chroma_format_idc == 3)
- get_bits1(&s->gb); //residual_color_transform_flag
- get_ue_golomb(&s->gb); //bit_depth_luma_minus8
- get_ue_golomb(&s->gb); //bit_depth_chroma_minus8
+ sps->residual_color_transform_flag = get_bits1(&s->gb);
+ sps->bit_depth_luma = get_ue_golomb(&s->gb) + 8;
+ sps->bit_depth_chroma = get_ue_golomb(&s->gb) + 8;
sps->transform_bypass = get_bits1(&s->gb);
decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8);
}else{
((const char*[]){"Gray","420","422","444"})[sps->chroma_format_idc]
);
}
+
av_free(h->sps_buffers[sps_id]);
h->sps_buffers[sps_id]= sps;
return 0;
H264Context *hx;
int i;
- if(avctx->codec_id == CODEC_ID_H264_VDPAU)
+ if(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
return;
if(context_count == 1) {
decode_slice(avctx, &h);
&& (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type_nos!=FF_B_TYPE)
&& (avctx->skip_frame < AVDISCARD_NONKEY || hx->slice_type_nos==FF_I_TYPE)
&& avctx->skip_frame < AVDISCARD_ALL){
- if(CONFIG_H264_VDPAU_DECODER && avctx->codec_id == CODEC_ID_H264_VDPAU){
+ if(CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
static const uint8_t start_code[] = {0x00, 0x00, 0x01};
ff_vdpau_add_data_chunk(s, start_code, sizeof(start_code));
ff_vdpau_add_data_chunk(s, &buf[buf_index - consumed], consumed );
s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
s->current_picture_ptr->pict_type= s->pict_type;
- if (CONFIG_H264_VDPAU_DECODER && avctx->codec_id == CODEC_ID_H264_VDPAU)
+ if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_set_reference_frames(s);
if(!s->dropable) {
h->prev_frame_num_offset= h->frame_num_offset;
h->prev_frame_num= h->frame_num;
- if (CONFIG_H264_VDPAU_DECODER && avctx->codec_id == CODEC_ID_H264_VDPAU)
+ if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_picture_complete(s);
/*
AVCodec h264_vdpau_decoder = {
"h264_vdpau",
CODEC_TYPE_VIDEO,
- CODEC_ID_H264_VDPAU,
+ CODEC_ID_H264,
sizeof(H264Context),
decode_init,
NULL,