mirror of https://github.com/FFmpeg/FFmpeg.git
This will allow decoupling the parser from the decoder.pull/235/head^2
parent
90ed6c5cf7
commit
e481458bc3
12 changed files with 214 additions and 150 deletions
@ -0,0 +1,86 @@ |
||||
/*
|
||||
* This file is part of Libav. |
||||
* |
||||
* Libav is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* Libav is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with Libav; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include "get_bits.h" |
||||
#include "golomb.h" |
||||
#include "h264.h" |
||||
#include "h264_parse.h" |
||||
|
||||
int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps, |
||||
const int *ref_count, int slice_type_nos, |
||||
H264PredWeightTable *pwt) |
||||
{ |
||||
int list, i; |
||||
int luma_def, chroma_def; |
||||
|
||||
pwt->use_weight = 0; |
||||
pwt->use_weight_chroma = 0; |
||||
pwt->luma_log2_weight_denom = get_ue_golomb(gb); |
||||
if (sps->chroma_format_idc) |
||||
pwt->chroma_log2_weight_denom = get_ue_golomb(gb); |
||||
luma_def = 1 << pwt->luma_log2_weight_denom; |
||||
chroma_def = 1 << pwt->chroma_log2_weight_denom; |
||||
|
||||
for (list = 0; list < 2; list++) { |
||||
pwt->luma_weight_flag[list] = 0; |
||||
pwt->chroma_weight_flag[list] = 0; |
||||
for (i = 0; i < ref_count[list]; i++) { |
||||
int luma_weight_flag, chroma_weight_flag; |
||||
|
||||
luma_weight_flag = get_bits1(gb); |
||||
if (luma_weight_flag) { |
||||
pwt->luma_weight[i][list][0] = get_se_golomb(gb); |
||||
pwt->luma_weight[i][list][1] = get_se_golomb(gb); |
||||
if (pwt->luma_weight[i][list][0] != luma_def || |
||||
pwt->luma_weight[i][list][1] != 0) { |
||||
pwt->use_weight = 1; |
||||
pwt->luma_weight_flag[list] = 1; |
||||
} |
||||
} else { |
||||
pwt->luma_weight[i][list][0] = luma_def; |
||||
pwt->luma_weight[i][list][1] = 0; |
||||
} |
||||
|
||||
if (sps->chroma_format_idc) { |
||||
chroma_weight_flag = get_bits1(gb); |
||||
if (chroma_weight_flag) { |
||||
int j; |
||||
for (j = 0; j < 2; j++) { |
||||
pwt->chroma_weight[i][list][j][0] = get_se_golomb(gb); |
||||
pwt->chroma_weight[i][list][j][1] = get_se_golomb(gb); |
||||
if (pwt->chroma_weight[i][list][j][0] != chroma_def || |
||||
pwt->chroma_weight[i][list][j][1] != 0) { |
||||
pwt->use_weight_chroma = 1; |
||||
pwt->chroma_weight_flag[list] = 1; |
||||
} |
||||
} |
||||
} else { |
||||
int j; |
||||
for (j = 0; j < 2; j++) { |
||||
pwt->chroma_weight[i][list][j][0] = chroma_def; |
||||
pwt->chroma_weight[i][list][j][1] = 0; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
if (slice_type_nos != AV_PICTURE_TYPE_B) |
||||
break; |
||||
} |
||||
pwt->use_weight = pwt->use_weight || pwt->use_weight_chroma; |
||||
return 0; |
||||
} |
@ -0,0 +1,48 @@ |
||||
/*
|
||||
* This file is part of Libav. |
||||
* |
||||
* Libav is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* Libav is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with Libav; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* H.264 decoder/parser shared code |
||||
*/ |
||||
|
||||
#ifndef AVCODEC_H264_PARSE_H |
||||
#define AVCODEC_H264_PARSE_H |
||||
|
||||
#include "get_bits.h" |
||||
|
||||
typedef struct H264PredWeightTable { |
||||
int use_weight; |
||||
int use_weight_chroma; |
||||
int luma_log2_weight_denom; |
||||
int chroma_log2_weight_denom; |
||||
int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
|
||||
int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
|
||||
// The following 2 can be changed to int8_t but that causes 10cpu cycles speedloss
|
||||
int luma_weight[48][2][2]; |
||||
int chroma_weight[48][2][2][2]; |
||||
int implicit_weight[48][48][2]; |
||||
} H264PredWeightTable; |
||||
|
||||
struct SPS; |
||||
|
||||
int ff_h264_pred_weight_table(GetBitContext *gb, const struct SPS *sps, |
||||
const int *ref_count, int slice_type_nos, |
||||
H264PredWeightTable *pwt); |
||||
|
||||
#endif /* AVCODEC_H264_PARSE_H */ |
Loading…
Reference in new issue