示例#1
0
        *is_packed_rgba = 0;
    }

    if (*is_packed_rgba) {
        line_step[0] = (av_get_bits_per_pixel(pix_desc))>>3;
        for (i = 0; i < 4; i++)
            color[rgba_map[i]] = rgba_color[i];

        line[0] = av_malloc(w * line_step[0]);
        for (i = 0; i < w; i++)
            memcpy(line[0] + i * line_step[0], color, line_step[0]);
    } else {
        int plane;

        color[RED  ] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
        color[GREEN] = RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
        color[BLUE ] = RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
        color[ALPHA] = rgba_color[3];

        for (plane = 0; plane < 4; plane++) {
            int line_size;
            int hsub1 = (plane == 1 || plane == 2) ? hsub : 0;

            line_step[plane] = 1;
            line_size = (w >> hsub1) * line_step[plane];
            line[plane] = av_malloc(line_size);
            memset(line[plane], color[plane], line_size);
        }
    }

    return 0;
示例#2
0
    if (*is_packed_rgba) {
        pixel_step[0] = (av_get_bits_per_pixel(pix_desc))>>3;
        for (i = 0; i < 4; i++)
            dst_color[rgba_map[i]] = rgba_color[i];

        line[0] = av_malloc(w * pixel_step[0]);
        for (i = 0; i < w; i++)
            memcpy(line[0] + i * pixel_step[0], dst_color, pixel_step[0]);
        if (rgba_map_ptr)
            memcpy(rgba_map_ptr, rgba_map, sizeof(rgba_map[0]) * 4);
    } else {
        int plane;

        dst_color[0] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
        dst_color[1] = RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
        dst_color[2] = RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
        dst_color[3] = rgba_color[3];

        for (plane = 0; plane < 4; plane++) {
            int line_size;
            int hsub1 = (plane == 1 || plane == 2) ? hsub : 0;

            pixel_step[plane] = 1;
            line_size = FF_CEIL_RSHIFT(w, hsub1) * pixel_step[plane];
            line[plane] = av_malloc(line_size);
            memset(line[plane], dst_color[plane], line_size);
        }
    }

    return 0;
示例#3
0
static void 
rgb24_to_yuv420p(AVPicture *dst, const AVPicture *src, int width, int height)
{
  int wrap, wrap3, width2;
  int r, g, b, r1, g1, b1, w;
  uint8_t *lum, *cb, *cr;
  const uint8_t *p;

  lum = dst->data[0];
  cb = dst->data[1];
  cr = dst->data[2];

  width2 = (width + 1) >> 1;
  wrap = dst->linesize[0];
  wrap3 = src->linesize[0];
  p = src->data[0];
  for (; height>=2 ; height-=2) {
    for(w = width ; w>=2 ; w-=2) {
      RGB_IN(r, g, b, p);
      r1 = r;
      g1 = g;
      b1 = b;
      lum[0] = RGB_TO_Y_CCIR(r, g, b);

      RGB_IN(r, g, b, p + BPP);
      r1 += r;
      g1 += g;
      b1 += b;
      lum[1] = RGB_TO_Y_CCIR(r, g, b);
      p += wrap3;
      lum += wrap;

      RGB_IN(r, g, b, p);
      r1 += r;
      g1 += g;
      b1 += b;
      lum[0] = RGB_TO_Y_CCIR(r, g, b);

      RGB_IN(r, g, b, p + BPP);
      r1 += r;
      g1 += g;
      b1 += b;
      lum[1] = RGB_TO_Y_CCIR(r, g, b);

      cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 2);
      cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 2);

      cb++;
      cr++;
      p += -wrap3 + 2 * BPP;
      lum += -wrap + 2;
    }
    if (w) {
      RGB_IN(r, g, b, p);
      r1 = r;
      g1 = g;
      b1 = b;
      lum[0] = RGB_TO_Y_CCIR(r, g, b);
      p += wrap3;
      lum += wrap;
      RGB_IN(r, g, b, p);
      r1 += r;
      g1 += g;
      b1 += b;
      lum[0] = RGB_TO_Y_CCIR(r, g, b);
      cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
      cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
      cb++;
      cr++;
      p += -wrap3 + BPP;
      lum += -wrap + 1;
    }
    p += wrap3 + (wrap3 - width * BPP);
    lum += wrap + (wrap - width);
    cb += dst->linesize[1] - width2;
    cr += dst->linesize[2] - width2;
  }
  /* handle odd height */
  if (height) {
    for(w = width; w >= 2; w -= 2) {
      RGB_IN(r, g, b, p);
      r1 = r;
      g1 = g;
      b1 = b;
      lum[0] = RGB_TO_Y_CCIR(r, g, b);

      RGB_IN(r, g, b, p + BPP);
      r1 += r;
      g1 += g;
      b1 += b;
      lum[1] = RGB_TO_Y_CCIR(r, g, b);
      cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
      cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
      cb++;
      cr++;
      p += 2 * BPP;
      lum += 2;
    }
    if (w) {
      RGB_IN(r, g, b, p);
      lum[0] = RGB_TO_Y_CCIR(r, g, b);
      cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
      cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
    }
  }
}