FFmpeg
Loading...
Searching...
No Matches
rv10enc.c
Go to the documentation of this file.
1/*
2 * RV10 encoder
3 * Copyright (c) 2000,2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23/**
24 * @file
25 * RV10 encoder
26 */
27
28#include "codec_internal.h"
29#include "mpegvideo.h"
30#include "mpegvideoenc.h"
31#include "put_bits.h"
32
34{
35 MPVEncContext *const s = &m->s;
36 int full_frame= 0;
37
39
40 put_bits(&s->pb, 1, 1); /* marker */
41
42 put_bits(&s->pb, 1, (s->c.pict_type == AV_PICTURE_TYPE_P));
43
44 put_bits(&s->pb, 1, 0); /* not PB-mframe */
45
46 put_bits(&s->pb, 5, s->c.qscale);
47
48 if (s->c.pict_type == AV_PICTURE_TYPE_I) {
49 /* specific MPEG like DC coding not used */
50 }
51 /* if multiple packets per frame are sent, the position at which
52 to display the macroblocks is coded here */
53 if(!full_frame){
54 put_bits(&s->pb, 6, 0); /* mb_x */
55 put_bits(&s->pb, 6, 0); /* mb_y */
56 put_bits(&s->pb, 12, s->c.mb_width * s->c.mb_height);
57 }
58
59 put_bits(&s->pb, 3, 0); /* ignored */
60 return 0;
61}
62
64{
65 MPVMainEncContext *const m = avctx->priv_data;
66
68
69 if ((avctx->width | avctx->height) & 15) {
70 av_log(avctx, AV_LOG_ERROR, "width and height must be a multiple of 16\n");
71 return AVERROR(EINVAL);
72 }
73 if (avctx->width * avctx->height >= 1U << 20) {
74 avpriv_report_missing_feature(avctx, "Encoding frames with %d (>= 4096) macroblocks",
75 avctx->width * avctx->height >> 8);
76 return AVERROR(ENOSYS);
77 }
78
79 return ff_mpv_encode_init(avctx);
80}
81
83 .p.name = "rv10",
84 CODEC_LONG_NAME("RealVideo 1.0"),
85 .p.type = AVMEDIA_TYPE_VIDEO,
86 .p.id = AV_CODEC_ID_RV10,
87 .p.priv_class = &ff_mpv_enc_class,
89 .priv_data_size = sizeof(MPVMainEncContext),
92 .close = ff_mpv_encode_end,
93 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
95 .color_ranges = AVCOL_RANGE_MPEG,
96};
const FFCodec ff_rv10_encoder
Definition rv10enc.c:82
#define s(width, name)
Definition cbs_vp9.c:198
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition codec.h:147
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
@ AV_CODEC_ID_RV10
Definition codec_id.h:55
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AV_PICTURE_TYPE_I
Intra.
Definition avutil.h:278
@ AV_PICTURE_TYPE_P
Predicted.
Definition avutil.h:279
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition j2kenc.c:154
#define av_cold
Definition attributes.h:117
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
mpegvideo header.
const AVClass ff_mpv_enc_class
av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet)
av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
mpegvideo header.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:766
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
bitstream writer API
static void put_bits_assume_flushed(const PutBitContext *s)
Inform the compiler that a PutBitContext is flushed (i.e.
Definition put_bits.h:82
static av_cold int rv10_encode_init(AVCodecContext *avctx)
Definition rv10enc.c:63
static int rv10_encode_picture_header(MPVMainEncContext *const m)
Definition rv10enc.c:33
main external API structure.
Definition avcodec.h:443
int width
picture width / height.
Definition avcodec.h:604
void * priv_data
Definition avcodec.h:470
MPVEncContext s
The main slicecontext.
int(* encode_picture_header)(struct MPVMainEncContext *m)
#define av_log(a,...)