]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'e481458bc308ee838deaeacac51929514762e7a7'
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>
Tue, 26 Apr 2016 14:04:29 +0000 (15:04 +0100)
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>
Tue, 26 Apr 2016 14:04:29 +0000 (15:04 +0100)
* commit 'e481458bc308ee838deaeacac51929514762e7a7':
  h264: factor out pred weight table parsing into a separate file

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
12 files changed:
1  2 
libavcodec/Makefile
libavcodec/dxva2_h264.c
libavcodec/h264.c
libavcodec/h264.h
libavcodec/h264_mb.c
libavcodec/h264_mc_template.c
libavcodec/h264_parse.c
libavcodec/h264_parse.h
libavcodec/h264_parser.c
libavcodec/h264_refs.c
libavcodec/h264_slice.c
libavcodec/vaapi_h264.c

index 36b65f758e6c12e84f02f0d581be1712432be552,54b12d35d359e2091b9d2ab55a47f89dcb10912b..4cda4dcb8d74631266c9be96fea47971a70a0953
@@@ -308,10 -251,10 +308,10 @@@ OBJS-$(CONFIG_H263_ENCODER)            
  OBJS-$(CONFIG_H264_DECODER)            += h264.o h264_cabac.o h264_cavlc.o \
                                            h264_direct.o h264_loopfilter.o  \
                                            h264_mb.o h264_picture.o h264_ps.o \
-                                           h264_refs.o h264_sei.o h264_slice.o h264data.o
 -                                          h264_refs.o h264_sei.o \
 -                                          h264_slice.o h264data.o h264_parse.o
++                                          h264_refs.o h264_sei.o h264_slice.o h264data.o h264_parse.o
 +OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h264.o
  OBJS-$(CONFIG_H264_MMAL_DECODER)       += mmaldec.o
 -OBJS-$(CONFIG_H264_NVENC_ENCODER)      += nvenc_h264.o
 +OBJS-$(CONFIG_H264_VDA_DECODER)        += vda_h264_dec.o
  OBJS-$(CONFIG_H264_QSV_DECODER)        += qsvdec_h2645.o
  OBJS-$(CONFIG_H264_QSV_ENCODER)        += qsvenc_h264.o
  OBJS-$(CONFIG_HAP_DECODER)             += hapdec.o hap.o
index b1abb9a9af6de584f8044b06939bd66885919cf5,2d6fa79152dd49394255529fc26ae76b098b9b07..7048c4aada915e06cbd6934975cc233cd98d10d1
@@@ -254,18 -252,18 +254,18 @@@ static void fill_slice_long(AVCodecCont
                  else
                      index = get_refpic_index(pp, ff_dxva2_get_surface_index(avctx, ctx, r->f));
                  fill_picture_entry(&slice->RefPicList[list][i], index,
 -                                   r->reference == PICT_BOTTOM_FIELD);
 +                                   sl->ref_list[list][i].reference == PICT_BOTTOM_FIELD);
                  for (plane = 0; plane < 3; plane++) {
                      int w, o;
-                     if (plane == 0 && sl->luma_weight_flag[list]) {
-                         w = sl->luma_weight[i][list][0];
-                         o = sl->luma_weight[i][list][1];
-                     } else if (plane >= 1 && sl->chroma_weight_flag[list]) {
-                         w = sl->chroma_weight[i][list][plane-1][0];
-                         o = sl->chroma_weight[i][list][plane-1][1];
+                     if (plane == 0 && sl->pwt.luma_weight_flag[list]) {
+                         w = sl->pwt.luma_weight[i][list][0];
+                         o = sl->pwt.luma_weight[i][list][1];
+                     } else if (plane >= 1 && sl->pwt.chroma_weight_flag[list]) {
+                         w = sl->pwt.chroma_weight[i][list][plane-1][0];
+                         o = sl->pwt.chroma_weight[i][list][plane-1][1];
                      } else {
-                         w = 1 << (plane == 0 ? sl->luma_log2_weight_denom :
-                                                sl->chroma_log2_weight_denom);
+                         w = 1 << (plane == 0 ? sl->pwt.luma_log2_weight_denom :
+                                                sl->pwt.chroma_log2_weight_denom);
                          o = 0;
                      }
                      slice->Weights[list][i][plane][0] = w;
Simple merge
Simple merge
index 8302de040ef128926b06d9eafaef5f82e2f1780b,f94333b590072e913b577224756b08c004073799..8791e2e182bc804dd8e60ab4f463ba5dbc908aee
@@@ -425,33 -424,29 +425,33 @@@ static av_always_inline void mc_part_we
              int weight1 = 64 - weight0;
              luma_weight_avg(dest_y, tmp_y, sl->mb_linesize,
                              height, 5, weight0, weight1, 0);
 -            chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize,
 -                              chroma_height, 5, weight0, weight1, 0);
 -            chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize,
 -                              chroma_height, 5, weight0, weight1, 0);
 +            if (!CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) {
 +                chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize,
 +                                  chroma_height, 5, weight0, weight1, 0);
 +                chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize,
 +                                  chroma_height, 5, weight0, weight1, 0);
 +            }
          } else {
              luma_weight_avg(dest_y, tmp_y, sl->mb_linesize, height,
-                             sl->luma_log2_weight_denom,
-                             sl->luma_weight[refn0][0][0],
-                             sl->luma_weight[refn1][1][0],
-                             sl->luma_weight[refn0][0][1] +
-                             sl->luma_weight[refn1][1][1]);
+                             sl->pwt.luma_log2_weight_denom,
+                             sl->pwt.luma_weight[refn0][0][0],
+                             sl->pwt.luma_weight[refn1][1][0],
+                             sl->pwt.luma_weight[refn0][0][1] +
+                             sl->pwt.luma_weight[refn1][1][1]);
 -            chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize, chroma_height,
 -                              sl->pwt.chroma_log2_weight_denom,
 -                              sl->pwt.chroma_weight[refn0][0][0][0],
 -                              sl->pwt.chroma_weight[refn1][1][0][0],
 -                              sl->pwt.chroma_weight[refn0][0][0][1] +
 -                              sl->pwt.chroma_weight[refn1][1][0][1]);
 -            chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize, chroma_height,
 -                              sl->pwt.chroma_log2_weight_denom,
 -                              sl->pwt.chroma_weight[refn0][0][1][0],
 -                              sl->pwt.chroma_weight[refn1][1][1][0],
 -                              sl->pwt.chroma_weight[refn0][0][1][1] +
 -                              sl->pwt.chroma_weight[refn1][1][1][1]);
 +            if (!CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) {
 +                chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize, chroma_height,
-                                   sl->chroma_log2_weight_denom,
-                                   sl->chroma_weight[refn0][0][0][0],
-                                   sl->chroma_weight[refn1][1][0][0],
-                                   sl->chroma_weight[refn0][0][0][1] +
-                                   sl->chroma_weight[refn1][1][0][1]);
++                                  sl->pwt.chroma_log2_weight_denom,
++                                  sl->pwt.chroma_weight[refn0][0][0][0],
++                                  sl->pwt.chroma_weight[refn1][1][0][0],
++                                  sl->pwt.chroma_weight[refn0][0][0][1] +
++                                  sl->pwt.chroma_weight[refn1][1][0][1]);
 +                chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize, chroma_height,
-                                   sl->chroma_log2_weight_denom,
-                                   sl->chroma_weight[refn0][0][1][0],
-                                   sl->chroma_weight[refn1][1][1][0],
-                                   sl->chroma_weight[refn0][0][1][1] +
-                                   sl->chroma_weight[refn1][1][1][1]);
++                                  sl->pwt.chroma_log2_weight_denom,
++                                  sl->pwt.chroma_weight[refn0][0][1][0],
++                                  sl->pwt.chroma_weight[refn1][1][1][0],
++                                  sl->pwt.chroma_weight[refn0][0][1][1] +
++                                  sl->pwt.chroma_weight[refn1][1][1][1]);
 +            }
          }
      } else {
          int list     = list1 ? 1 : 0;
                      qpix_put, chroma_put, pixel_shift, chroma_idc);
  
          luma_weight_op(dest_y, sl->mb_linesize, height,
-                        sl->luma_log2_weight_denom,
-                        sl->luma_weight[refn][list][0],
-                        sl->luma_weight[refn][list][1]);
+                        sl->pwt.luma_log2_weight_denom,
+                        sl->pwt.luma_weight[refn][list][0],
+                        sl->pwt.luma_weight[refn][list][1]);
 -        if (sl->pwt.use_weight_chroma) {
 -            chroma_weight_op(dest_cb, sl->mb_uvlinesize, chroma_height,
 -                             sl->pwt.chroma_log2_weight_denom,
 -                             sl->pwt.chroma_weight[refn][list][0][0],
 -                             sl->pwt.chroma_weight[refn][list][0][1]);
 -            chroma_weight_op(dest_cr, sl->mb_uvlinesize, chroma_height,
 -                             sl->pwt.chroma_log2_weight_denom,
 -                             sl->pwt.chroma_weight[refn][list][1][0],
 -                             sl->pwt.chroma_weight[refn][list][1][1]);
 +        if (!CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) {
-             if (sl->use_weight_chroma) {
++            if (sl->pwt.use_weight_chroma) {
 +                chroma_weight_op(dest_cb, sl->mb_uvlinesize, chroma_height,
-                                  sl->chroma_log2_weight_denom,
-                                  sl->chroma_weight[refn][list][0][0],
-                                  sl->chroma_weight[refn][list][0][1]);
++                                 sl->pwt.chroma_log2_weight_denom,
++                                 sl->pwt.chroma_weight[refn][list][0][0],
++                                 sl->pwt.chroma_weight[refn][list][0][1]);
 +                chroma_weight_op(dest_cr, sl->mb_uvlinesize, chroma_height,
-                                  sl->chroma_log2_weight_denom,
-                                  sl->chroma_weight[refn][list][1][0],
-                                  sl->chroma_weight[refn][list][1][1]);
++                                 sl->pwt.chroma_log2_weight_denom,
++                                 sl->pwt.chroma_weight[refn][list][1][0],
++                                 sl->pwt.chroma_weight[refn][list][1][1]);
 +            }
          }
      }
  }
Simple merge
index 0000000000000000000000000000000000000000,88caa48f1928b3e38d212bc93b1d74031f04dc47..ebd87b0e5b97ebd1ab7f2fe3f86acea95899af78
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,86 +1,96 @@@
 - * This file is part of Libav.
+ /*
 - * Libav is free software; you can redistribute it and/or
++ * This file is part of FFmpeg.
+  *
 - * Libav is distributed in the hope that it will be useful,
++ * FFmpeg 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.
+  *
 - * License along with Libav; if not, write to the Free Software
++ * FFmpeg 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 FFmpeg; 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);
++
++    if (pwt->luma_log2_weight_denom > 7U) {
++        av_log(NULL, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of range\n", pwt->luma_log2_weight_denom);
++        pwt->luma_log2_weight_denom = 0;
++    }
++    if (pwt->chroma_log2_weight_denom > 7U) {
++        av_log(NULL, AV_LOG_ERROR, "chroma_log2_weight_denom %d is out of range\n", pwt->chroma_log2_weight_denom);
++        pwt->chroma_log2_weight_denom = 0;
++    }
++
+     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;
+ }
index 0000000000000000000000000000000000000000,7bdce04a3b896d060fb6cf0f3d90a0b520bdf019..d1a7af08e819497f76c4ff89df6676ccfea94bf9
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,48 +1,48 @@@
 - * This file is part of Libav.
+ /*
 - * Libav is free software; you can redistribute it and/or
++ * This file is part of FFmpeg.
+  *
 - * Libav is distributed in the hope that it will be useful,
++ * FFmpeg 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.
+  *
 - * License along with Libav; if not, write to the Free Software
++ * FFmpeg 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 FFmpeg; 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 */
Simple merge
Simple merge
index f0f0a50a55a260eb5912e34e9504b96725288d23,49d7e6c21533446e7752f7d77c8190c2e1aeb02b..880b69602e3e7425eef244a06f7859a4abbf6193
@@@ -781,9 -737,9 +781,9 @@@ static void implicit_weight_table(cons
              cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure - 1];
          }
          if (sl->ref_count[0] == 1 && sl->ref_count[1] == 1 && !FRAME_MBAFF(h) &&
 -            sl->ref_list[0][0].poc + sl->ref_list[1][0].poc == 2 * cur_poc) {
 +            sl->ref_list[0][0].poc + (int64_t)sl->ref_list[1][0].poc == 2 * cur_poc) {
-             sl->use_weight        = 0;
-             sl->use_weight_chroma = 0;
+             sl->pwt.use_weight        = 0;
+             sl->pwt.use_weight_chroma = 0;
              return;
          }
          ref_start  = 0;
          ref_count1 = 16 + 2 * sl->ref_count[1];
      }
  
-     sl->use_weight               = 2;
-     sl->use_weight_chroma        = 2;
-     sl->luma_log2_weight_denom   = 5;
-     sl->chroma_log2_weight_denom = 5;
+     sl->pwt.use_weight               = 2;
+     sl->pwt.use_weight_chroma        = 2;
+     sl->pwt.luma_log2_weight_denom   = 5;
+     sl->pwt.chroma_log2_weight_denom = 5;
  
      for (ref0 = ref_start; ref0 < ref_count0; ref0++) {
 -        int poc0 = sl->ref_list[0][ref0].poc;
 +        int64_t poc0 = sl->ref_list[0][ref0].poc;
          for (ref1 = ref_start; ref1 < ref_count1; ref1++) {
              int w = 32;
              if (!sl->ref_list[0][ref0].parent->long_ref && !sl->ref_list[1][ref1].parent->long_ref) {
Simple merge