2
2
* H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
3
3
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
5
* This file is part of FFmpeg.
5
* This file is part of Libav.
7
* FFmpeg is free software; you can redistribute it and/or
7
* Libav is free software; you can redistribute it and/or
8
8
* modify it under the terms of the GNU Lesser General Public
9
9
* License as published by the Free Software Foundation; either
10
10
* version 2.1 of the License, or (at your option) any later version.
12
* FFmpeg is distributed in the hope that it will be useful,
12
* Libav is distributed in the hope that it will be useful,
13
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
15
* Lesser General Public License for more details.
17
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
18
* License along with Libav; if not, write to the Free Software
19
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
39
39
#define interlaced_dct interlaced_dct_is_a_bad_name
40
40
#define mb_intra mb_intra_is_not_initialized_see_mb_type
42
#define LUMA_DC_BLOCK_INDEX 25
43
#define CHROMA_DC_BLOCK_INDEX 26
42
#define LUMA_DC_BLOCK_INDEX 24
43
#define CHROMA_DC_BLOCK_INDEX 25
45
45
#define CHROMA_DC_COEFF_TOKEN_VLC_BITS 8
46
46
#define COEFF_TOKEN_VLC_BITS 8
209
209
int bit_depth_luma; ///< bit_depth_luma_minus8 + 8
210
210
int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8
211
211
int residual_color_transform_flag; ///< residual_colour_transform_flag
212
int constraint_set_flags; ///< constraint_set[0-3]_flag
406
407
GetBitContext *inter_gb_ptr;
408
409
DECLARE_ALIGNED(16, DCTELEM, mb)[16*24];
410
DECLARE_ALIGNED(16, DCTELEM, mb_luma_dc)[16];
409
411
DCTELEM mb_padding[256]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too large or ensure that there is some unused stuff after mb
465
467
int is_avc; ///< this flag is != 0 if codec is avc1
466
468
int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
469
int got_first; ///< this flag is != 0 if we've parsed a frame
468
471
SPS *sps_buffers[MAX_SPS_COUNT];
469
472
PPS *pps_buffers[MAX_PPS_COUNT];
600
603
extern const uint8_t ff_h264_chroma_qp[52];
602
void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp);
604
void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc);
614
613
int ff_h264_decode_seq_parameter_set(H264Context *h);
616
* compute profile from sps
618
int ff_h264_get_profile(SPS *sps);
619
623
int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length);
622
* Decodes a network abstraction layer unit.
626
* Decode a network abstraction layer unit.
623
627
* @param consumed is the number of bytes used as input
624
628
* @param length is the length of the array
625
629
* @param dst_length is the number of decoded bytes FIXME here or a decode rbsp tailing?
628
632
const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length);
631
* identifies the exact end of the bitstream
632
* @return the length of the trailing, or 0 if damaged
634
int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src);
637
* frees any data that may have been allocated in the H264 context like SPS, PPS etc.
635
* Free any data that may have been allocated in the H264 context like SPS, PPS etc.
639
637
av_cold void ff_h264_free_context(H264Context *h);
642
* reconstructs bitstream slice_type.
640
* Reconstruct bitstream slice_type.
644
642
int ff_h264_get_slice_type(const H264Context *h);
648
646
* needs width/height
650
648
int ff_h264_alloc_tables(H264Context *h);
653
* fills the default_ref_list.
651
* Fill the default_ref_list.
655
653
int ff_h264_fill_default_ref_list(H264Context *h);
659
657
void ff_h264_remove_all_refs(H264Context *h);
662
* Executes the reference picture marking (memory management control operations).
660
* Execute the reference picture marking (memory management control operations).
664
662
int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count);
666
664
int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb);
666
void ff_generate_sliding_window_mmcos(H264Context *h);
670
* checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
670
* Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks.
672
672
int ff_h264_check_intra4x4_pred_mode(H264Context *h);
675
* checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
675
* Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks.
677
677
int ff_h264_check_intra_pred_mode(H264Context *h, int mode);
679
679
void ff_h264_write_back_intra_pred_mode(H264Context *h);
680
680
void ff_h264_hl_decode_mb(H264Context *h);
681
681
int ff_h264_frame_start(H264Context *h);
682
int ff_h264_decode_extradata(H264Context *h);
682
683
av_cold int ff_h264_decode_init(AVCodecContext *avctx);
683
684
av_cold int ff_h264_decode_end(AVCodecContext *avctx);
684
685
av_cold void ff_h264_decode_init_vlc(void);
687
* decodes a macroblock
688
* Decode a macroblock
688
689
* @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
690
691
int ff_h264_decode_mb_cavlc(H264Context *h);
693
* decodes a CABAC coded macroblock
694
* Decode a CABAC coded macroblock
694
695
* @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
696
697
int ff_h264_decode_mb_cabac(H264Context *h);
726
/* Scan8 organization:
734
* DY/DU/DV are for luma/chroma DC.
724
737
//This table must be here because scan8[constant] must be known at compiletime
725
static const uint8_t scan8[16 + 2*4]={
738
static const uint8_t scan8[16 + 2*4 + 3]={
726
739
4+1*8, 5+1*8, 4+2*8, 5+2*8,
727
740
6+1*8, 7+1*8, 6+2*8, 7+2*8,
728
741
4+3*8, 5+3*8, 4+4*8, 5+4*8,
1254
1268
* decodes a P_SKIP or B_SKIP macroblock
1256
static void decode_mb_skip(H264Context *h){
1270
static void av_unused decode_mb_skip(H264Context *h){
1257
1271
MpegEncContext * const s = &h->s;
1258
1272
const int mb_xy= h->mb_xy;