diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
| commit | f7813a5324be39d13ab536c245d15dfc602a7849 (patch) | |
| tree | fad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/msvideo1enc.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/msvideo1enc.c')
| -rw-r--r-- | ffmpeg/libavcodec/msvideo1enc.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/ffmpeg/libavcodec/msvideo1enc.c b/ffmpeg/libavcodec/msvideo1enc.c index e0efb48..9928250 100644 --- a/ffmpeg/libavcodec/msvideo1enc.c +++ b/ffmpeg/libavcodec/msvideo1enc.c @@ -35,7 +35,6 @@ */ typedef struct Msvideo1EncContext { AVCodecContext *avctx; - AVFrame pic; AVLFG rnd; uint8_t *prev; @@ -67,7 +66,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { Msvideo1EncContext * const c = avctx->priv_data; - AVFrame * const p = &c->pic; + const AVFrame *p = pict; uint16_t *src; uint8_t *prevptr; uint8_t *dst, *buf; @@ -75,12 +74,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, int no_skips = 1; int i, j, k, x, y, ret; int skips = 0; + int quality = 24; if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*9 + FF_MIN_BUFFER_SIZE)) < 0) return ret; dst= buf= pkt->data; - *p = *pict; if(!c->prev) c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3)); prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1); @@ -88,7 +87,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, if(c->keyint >= avctx->keyint_min) keyframe = 1; - p->quality = 24; for(y = 0; y < avctx->height; y += 4){ for(x = 0; x < avctx->width; x += 4){ @@ -114,12 +112,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, bestscore += t*t; } } - bestscore /= p->quality; + bestscore /= quality; } // try to find optimal value to fill whole 4x4 block score = 0; - ff_init_elbg(c->block, 3, 16, c->avg, 1, 1, c->output, &c->rnd); - ff_do_elbg (c->block, 3, 16, c->avg, 1, 1, c->output, &c->rnd); + avpriv_init_elbg(c->block, 3, 16, c->avg, 1, 1, c->output, &c->rnd); + avpriv_do_elbg (c->block, 3, 16, c->avg, 1, 1, c->output, &c->rnd); if(c->avg[0] == 1) // red component = 1 will be written as skip code c->avg[0] = 0; for(j = 0; j < 4; j++){ @@ -130,7 +128,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } } } - score /= p->quality; + score /= quality; score += 2; if(score < bestscore){ bestscore = score; @@ -138,8 +136,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } // search for optimal filling of 2-color block score = 0; - ff_init_elbg(c->block, 3, 16, c->codebook, 2, 1, c->output, &c->rnd); - ff_do_elbg (c->block, 3, 16, c->codebook, 2, 1, c->output, &c->rnd); + avpriv_init_elbg(c->block, 3, 16, c->codebook, 2, 1, c->output, &c->rnd); + avpriv_do_elbg (c->block, 3, 16, c->codebook, 2, 1, c->output, &c->rnd); // last output value should be always 1, swap codebooks if needed if(!c->output[15]){ for(i = 0; i < 3; i++) @@ -155,7 +153,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } } } - score /= p->quality; + score /= quality; score += 6; if(score < bestscore){ bestscore = score; @@ -164,8 +162,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, // search for optimal filling of 2-color 2x2 subblocks score = 0; for(i = 0; i < 4; i++){ - ff_init_elbg(c->block2 + i*4*3, 3, 4, c->codebook2 + i*2*3, 2, 1, c->output2 + i*4, &c->rnd); - ff_do_elbg (c->block2 + i*4*3, 3, 4, c->codebook2 + i*2*3, 2, 1, c->output2 + i*4, &c->rnd); + avpriv_init_elbg(c->block2 + i*4*3, 3, 4, c->codebook2 + i*2*3, 2, 1, c->output2 + i*4, &c->rnd); + avpriv_do_elbg (c->block2 + i*4*3, 3, 4, c->codebook2 + i*2*3, 2, 1, c->output2 + i*4, &c->rnd); } // last value should be always 1, swap codebooks if needed if(!c->output2[15]){ @@ -182,7 +180,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } } } - score /= p->quality; + score /= quality; score += 18; if(score < bestscore){ bestscore = score; @@ -248,8 +246,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, c->keyint = 0; else c->keyint++; - p->pict_type= keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; - p->key_frame= keyframe; if (keyframe) pkt->flags |= AV_PKT_FLAG_KEY; pkt->size = dst - buf; *got_packet = 1; @@ -274,8 +270,6 @@ static av_cold int encode_init(AVCodecContext *avctx) return -1; } - avcodec_get_frame_defaults(&c->pic); - avctx->coded_frame = (AVFrame*)&c->pic; avctx->bits_per_coded_sample = 16; c->keyint = avctx->keyint_min; @@ -300,6 +294,7 @@ static av_cold int encode_end(AVCodecContext *avctx) AVCodec ff_msvideo1_encoder = { .name = "msvideo1", + .long_name = NULL_IF_CONFIG_SMALL("Microsoft Video-1"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_MSVIDEO1, .priv_data_size = sizeof(Msvideo1EncContext), @@ -307,5 +302,4 @@ AVCodec ff_msvideo1_encoder = { .encode2 = encode_frame, .close = encode_end, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_RGB555, AV_PIX_FMT_NONE}, - .long_name = NULL_IF_CONFIG_SMALL("Microsoft Video-1"), }; |
