~ubuntu-branches/ubuntu/saucy/gst-libav1.0/saucy-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavcodec/flashsvenc.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-30 09:00:15 UTC
  • mfrom: (1.1.16) (7.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20130730090015-sc1ou2yssu7q5w4e
Tags: 1.1.3-1
* New upstream development snapshot:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.1.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include <zlib.h>
50
50
 
51
51
#include "avcodec.h"
 
52
#include "internal.h"
52
53
#include "put_bits.h"
53
54
#include "bytestream.h"
54
55
 
194
195
}
195
196
 
196
197
 
197
 
static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf,
198
 
                                int buf_size, void *data)
 
198
static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
199
                                const AVFrame *pict, int *got_packet)
199
200
{
200
201
    FlashSVContext * const s = avctx->priv_data;
201
 
    AVFrame *pict = data;
202
202
    AVFrame * const p = &s->frame;
203
203
    uint8_t *pfptr;
204
204
    int res;
228
228
        I_frame = 1;
229
229
    }
230
230
 
231
 
    if (buf_size < s->image_width * s->image_height * 3) {
 
231
    if ((res = ff_alloc_packet(pkt, s->image_width * s->image_height * 3)) < 0) {
232
232
        //Conservative upper bound check for compressed data
233
 
        av_log(avctx, AV_LOG_ERROR, "buf_size %d <  %d\n",
234
 
               buf_size, s->image_width * s->image_height * 3);
235
 
        return -1;
 
233
        av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n",
 
234
               s->image_width * s->image_height * 3);
 
235
        return res;
236
236
    }
237
237
 
238
 
    res = encode_bitstream(s, p, buf, buf_size, opt_w * 16, opt_h * 16,
239
 
                           pfptr, &I_frame);
 
238
    pkt->size = encode_bitstream(s, p, pkt->data, pkt->size, opt_w * 16, opt_h * 16,
 
239
                                 pfptr, &I_frame);
240
240
 
241
241
    //save the current frame
242
242
    if (p->linesize[0] > 0)
259
259
 
260
260
    avctx->coded_frame = p;
261
261
 
262
 
    return res;
 
262
    if (p->key_frame)
 
263
        pkt->flags |= AV_PKT_FLAG_KEY;
 
264
    *got_packet = 1;
 
265
 
 
266
    return 0;
263
267
}
264
268
 
265
269
static av_cold int flashsv_encode_end(AVCodecContext *avctx)
278
282
AVCodec ff_flashsv_encoder = {
279
283
    .name           = "flashsv",
280
284
    .type           = AVMEDIA_TYPE_VIDEO,
281
 
    .id             = CODEC_ID_FLASHSV,
 
285
    .id             = AV_CODEC_ID_FLASHSV,
282
286
    .priv_data_size = sizeof(FlashSVContext),
283
287
    .init           = flashsv_encode_init,
284
 
    .encode         = flashsv_encode_frame,
 
288
    .encode2        = flashsv_encode_frame,
285
289
    .close          = flashsv_encode_end,
286
 
    .pix_fmts       = (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_NONE},
 
290
    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE },
287
291
    .long_name      = NULL_IF_CONFIG_SMALL("Flash Screen Video"),
288
292
};
289