OSDN Git Service

Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 13 Feb 2012 00:39:11 +0000 (01:39 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 13 Feb 2012 01:06:44 +0000 (02:06 +0100)
* qatar/master:
  swscale: convert yuv2yuvX() to using named arguments.
  swscale: rename "dstw" to "w" to prevent name collisions.
  swscale: use named registers in yuv2yuv1_plane() place.
  lavf: fix aspect ratio mismatch message.
  avconv: set AVFormatContext.duration from '-t'
  cljr: implement encode2.
  cljr: set the properties of the coded_frame, not input frame.
  dnxhdenc: switch to encode2.
  bmpenc: switch to encode2().

Conflicts:
libavcodec/bmpenc.c
libavcodec/cljr.c
libavformat/utils.c
tests/ref/vsynth1/cljr
tests/ref/vsynth2/cljr

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
ffmpeg.c
libavcodec/bmpenc.c
libavcodec/cljr.c
libavcodec/dnxhdenc.c
libswscale/x86/output.asm

diff --cc ffmpeg.c
Simple merge
@@@ -24,7 -24,7 +24,8 @@@
  #include "avcodec.h"
  #include "bytestream.h"
  #include "bmp.h"
 +#include <assert.h>
+ #include "internal.h"
  
  static const uint32_t monoblack_pal[] = { 0x000000, 0xFFFFFF };
  static const uint32_t rgb565_masks[]  = { 0xF800, 0x07E0, 0x001F };
@@@ -67,17 -64,16 +68,17 @@@ static av_cold int bmp_encode_init(AVCo
      return 0;
  }
  
- static int bmp_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
+ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+                             const AVFrame *pict, int *got_packet)
+ {
      BMPContext *s = avctx->priv_data;
-     AVFrame *pict = data;
      AVFrame * const p= (AVFrame*)&s->picture;
-     int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize;
+     int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize, ret;
      const uint32_t *pal = NULL;
 +    uint32_t palette256[256];
      int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB;
      int bit_count = avctx->bits_per_coded_sample;
-     uint8_t *ptr;
-     unsigned char* buf0 = buf;
+     uint8_t *ptr, *buf;
      *p = *pict;
      p->pict_type= AV_PICTURE_TYPE_I;
      p->key_frame= 1;
@@@ -168,10 -165,10 +173,10 @@@ AVCodec ff_bmp_encoder = 
      .id             = CODEC_ID_BMP,
      .priv_data_size = sizeof(BMPContext),
      .init           = bmp_encode_init,
-     .encode         = bmp_encode_frame,
+     .encode2        = bmp_encode_frame,
      .pix_fmts = (const enum PixelFormat[]){
 -        PIX_FMT_BGR24,
 -        PIX_FMT_RGB555, PIX_FMT_RGB444, PIX_FMT_RGB565,
 +        PIX_FMT_BGRA, PIX_FMT_BGR24,
 +        PIX_FMT_RGB565, PIX_FMT_RGB555, PIX_FMT_RGB444,
          PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8,
          PIX_FMT_MONOBLACK,
          PIX_FMT_NONE},
@@@ -25,8 -25,8 +25,9 @@@
   */
  
  #include "avcodec.h"
 +#include "libavutil/opt.h"
  #include "get_bits.h"
+ #include "internal.h"
  #include "put_bits.h"
  
  typedef struct CLJRContext {
@@@ -132,24 -129,21 +133,28 @@@ AVCodec ff_cljr_decoder = 
  #endif
  
  #if CONFIG_CLJR_ENCODER
- static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
-                         int buf_size, void *data)
+ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+                         const AVFrame *p, int *got_packet)
  {
 +    CLJRContext *a = avctx->priv_data;
      PutBitContext pb;
-     AVFrame *p = data;
-     int x, y;
+     int x, y, ret;
 +    uint32_t dither= avctx->frame_number;
 +    static const uint32_t ordered_dither[2][2] =
 +    {
 +        { 0x10400000, 0x104F0000 },
 +        { 0xCB2A0000, 0xCB250000 },
 +    };
  
-     p->pict_type = AV_PICTURE_TYPE_I;
-     p->key_frame = 1;
+     if ((ret = ff_alloc_packet(pkt, 32*avctx->height*avctx->width/4)) < 0) {
+         av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
+         return ret;
+     }
+     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+     avctx->coded_frame->key_frame = 1;
  
-     init_put_bits(&pb, buf, buf_size / 8);
+     init_put_bits(&pb, pkt->data, pkt->size);
  
      for (y = 0; y < avctx->height; y++) {
          uint8_t *luma = &p->data[0][y * p->linesize[0]];
  
      flush_put_bits(&pb);
  
-     return put_bits_count(&pb) / 8;
+     pkt->size   = put_bits_count(&pb) / 8;
+     pkt->flags |= AV_PKT_FLAG_KEY;
+     *got_packet = 1;
+     return 0;
  }
  
 +#define OFFSET(x) offsetof(CLJRContext, x)
 +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 +static const AVOption options[] = {
 +    { "dither_type",   "Dither type",   OFFSET(dither_type),        AV_OPT_TYPE_INT, { .dbl=1 }, 0, 2, VE},
 +    { NULL },
 +};
 +
 +static const AVClass class = {
 +    .class_name = "cljr encoder",
 +    .item_name  = av_default_item_name,
 +    .option     = options,
 +    .version    = LIBAVUTIL_VERSION_INT,
 +};
 +
  AVCodec ff_cljr_encoder = {
      .name           = "cljr",
      .type           = AVMEDIA_TYPE_VIDEO,
Simple merge
Simple merge