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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-09-24 17:07:00 UTC
  • mfrom: (1.1.17) (7.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20130924170700-4dg62s3pwl0pdakz
Tags: 1.2.0-1
* New upstream stable release:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.2.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
21
 */
22
22
 
 
23
#include "libavutil/common.h"
23
24
#include "libavutil/intreadwrite.h"
24
25
#include "avcodec.h"
 
26
#include "internal.h"
25
27
 
26
28
static av_cold int v410_encode_init(AVCodecContext *avctx)
27
29
{
40
42
    return 0;
41
43
}
42
44
 
43
 
static int v410_encode_frame(AVCodecContext *avctx, uint8_t *buf,
44
 
                             int buf_size, void *data)
 
45
static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
46
                             const AVFrame *pic, int *got_packet)
45
47
{
46
 
    AVFrame *pic = data;
47
 
    uint8_t *dst = buf;
 
48
    uint8_t *dst;
48
49
    uint16_t *y, *u, *v;
49
50
    uint32_t val;
50
 
    int i, j;
51
 
    int output_size = 0;
 
51
    int i, j, ret;
52
52
 
53
 
    if (buf_size < avctx->width * avctx->height * 4) {
54
 
        av_log(avctx, AV_LOG_ERROR, "Out buffer is too small.\n");
55
 
        return AVERROR(ENOMEM);
 
53
    if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * 4)) < 0) {
 
54
        av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
 
55
        return ret;
56
56
    }
 
57
    dst = pkt->data;
57
58
 
58
59
    avctx->coded_frame->reference = 0;
59
60
    avctx->coded_frame->key_frame = 1;
70
71
            val |= (uint32_t) v[j] << 22;
71
72
            AV_WL32(dst, val);
72
73
            dst += 4;
73
 
            output_size += 4;
74
74
        }
75
75
        y += pic->linesize[0] >> 1;
76
76
        u += pic->linesize[1] >> 1;
77
77
        v += pic->linesize[2] >> 1;
78
78
    }
79
79
 
80
 
    return output_size;
 
80
    pkt->flags |= AV_PKT_FLAG_KEY;
 
81
    *got_packet = 1;
 
82
    return 0;
81
83
}
82
84
 
83
85
static av_cold int v410_encode_close(AVCodecContext *avctx)
90
92
AVCodec ff_v410_encoder = {
91
93
    .name         = "v410",
92
94
    .type         = AVMEDIA_TYPE_VIDEO,
93
 
    .id           = CODEC_ID_V410,
 
95
    .id           = AV_CODEC_ID_V410,
94
96
    .init         = v410_encode_init,
95
 
    .encode       = v410_encode_frame,
 
97
    .encode2      = v410_encode_frame,
96
98
    .close        = v410_encode_close,
97
 
    .pix_fmts     = (const enum PixelFormat[]){ PIX_FMT_YUV444P10, PIX_FMT_NONE },
 
99
    .pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_NONE },
98
100
    .long_name    = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"),
99
101
};