<commit_before>/*
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "vpx_config.h"
#include "vpx_dsp_rtcd.h"
#include "vp8_rtcd.h"
#include "vpx_dsp/postproc.h"
#include "vpx_ports/system_state.h"
#include "vpx_scale_rtcd.h"
#include "vpx_scale/yv12config.h"
#include "postproc.h"
#include "common.h"
#include "vpx_scale/vpx_scale.h"
#include "systemdependent.h"

#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

/* clang-format off */
#define RGB_TO_YUV(t)                                     \
  (unsigned char)((0.257 * (float)(t >> 16)) +            \
                  (0.504 * (float)(t >> 8 & 0xff)) +      \
                  (0.098 * (float)(t & 0xff)) + 16),      \
  (unsigned char)(-(0.148 * (float)(t >> 16)) -           \
                  (0.291 * (float)(t >> 8 & 0xff)) +      \
                  (0.439 * (float)(t & 0xff)) + 128),     \
  (unsigned char)((0.439 * (float)(t >> 16)) -            \
                  (0.368 * (float)(t >> 8 & 0xff)) -      \
                  (0.071 * (float)(t & 0xff)) + 128)
/* clang-format on */

extern void vp8_blit_text(const char *msg, unsigned char *address,
                          const int pitch);
extern void vp8_blit_line(int x0, int x1, int y0, int y1, unsigned char *image,
                          const int pitch);
/***********************************************************************************************************
 */
#if CONFIG_POSTPROC
static int q2mbl(int x) {
  if (x < 20) x = 20;

  x = 50 + (x - 50) * 10 / 8;
  return x * x / 3;
}

static void vp8_de_mblock(YV12_BUFFER_CONFIG *post, int q) {
  vpx_mbpost_proc_across_ip(post->y_buffer, post->y_stride, post->y_height,
                            post->y_width, q2mbl(q));
  vpx_mbpost_proc_down(post->y_buffer, post->y_stride, post->y_height,
                       post->y_width, q2mbl(q));
}

void vp8_deblock(VP8_COMMON *cm, YV12_BUFFER_CONFIG *source,
                 YV12_BUFFER_CONFIG *post, int q, int low_var_thresh,
                 int flag) {
  double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
  int ppl = (int)(level + .5);

  const MODE_INFO *mode_info_context = cm->show_frame_mi;
  int mbr, mbc;

  /* The pixel thresholds are adjusted according to if or not the macroblock
   * is a skipped block.  */
  unsigned char *ylimits = cm->pp_limits_buffer;
  unsigned char *uvlimits = cm->pp_limits_buffer + 16 * cm->mb_cols;
  (void)low_var_thresh;
  (void)flag;

  if (ppl > 0) {
    for (mbr = 0; mbr < cm->mb_rows; ++mbr) {<commit_msg>VP8: Fix use-after-free in postproc.<commit_after>/*
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "vpx_config.h"
#include "vpx_dsp_rtcd.h"
#include "vp8_rtcd.h"
#include "vpx_dsp/postproc.h"
#include "vpx_ports/system_state.h"
#include "vpx_scale_rtcd.h"
#include "vpx_scale/yv12config.h"
#include "postproc.h"
#include "common.h"
#include "vpx_scale/vpx_scale.h"
#include "systemdependent.h"

#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

/* clang-format off */
#define RGB_TO_YUV(t)                                     \
  (unsigned char)((0.257 * (float)(t >> 16)) +            \
                  (0.504 * (float)(t >> 8 & 0xff)) +      \
                  (0.098 * (float)(t & 0xff)) + 16),      \
  (unsigned char)(-(0.148 * (float)(t >> 16)) -           \
                  (0.291 * (float)(t >> 8 & 0xff)) +      \
                  (0.439 * (float)(t & 0xff)) + 128),     \
  (unsigned char)((0.439 * (float)(t >> 16)) -            \
                  (0.368 * (float)(t >> 8 & 0xff)) -      \
                  (0.071 * (float)(t & 0xff)) + 128)
/* clang-format on */

extern void vp8_blit_text(const char *msg, unsigned char *address,
                          const int pitch);
extern void vp8_blit_line(int x0, int x1, int y0, int y1, unsigned char *image,
                          const int pitch);
/***********************************************************************************************************
 */
#if CONFIG_POSTPROC
static int q2mbl(int x) {
  if (x < 20) x = 20;

  x = 50 + (x - 50) * 10 / 8;
  return x * x / 3;
}

static void vp8_de_mblock(YV12_BUFFER_CONFIG *post, int q) {
  vpx_mbpost_proc_across_ip(post->y_buffer, post->y_stride, post->y_height,
                            post->y_width, q2mbl(q));
  vpx_mbpost_proc_down(post->y_buffer, post->y_stride, post->y_height,
                       post->y_width, q2mbl(q));
}

void vp8_deblock(VP8_COMMON *cm, YV12_BUFFER_CONFIG *source,
                 YV12_BUFFER_CONFIG *post, int q, int low_var_thresh,
                 int flag) {
  double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
  int ppl = (int)(level + .5);

  const MODE_INFO *mode_info_context = cm->mi;
  int mbr, mbc;

  /* The pixel thresholds are adjusted according to if or not the macroblock
   * is a skipped block.  */
  unsigned char *ylimits = cm->pp_limits_buffer;
  unsigned char *uvlimits = cm->pp_limits_buffer + 16 * cm->mb_cols;
  (void)low_var_thresh;
  (void)flag;

  if (ppl > 0) {
    for (mbr = 0; mbr < cm->mb_rows; ++mbr) {
{'fraction_non_alphanumeric': 0.16941015089163236, 'fraction_numerical': 0.0399519890260631, 'mean_word_length': 2.3834106728538282, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6306048', 'n_tokens_mistral': 2226, 'n_tokens_neox': 2031, 'n_words': 558}