diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-02-16 12:13:27 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-02-16 13:13:18 +0100 |
commit | a53b144ec041ce6a7f7bd16115e41a8194b95ef7 (patch) | |
tree | e918ff9b36d9679c54ad31a38290d1e07cdadc71 | |
parent | af882e1819cae65f6ec026567ed4e99869236782 (diff) | |
download | ffmpeg-a53b144ec041ce6a7f7bd16115e41a8194b95ef7.tar.gz |
avcodec: add avpriv_color_frame()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/internal.h | 3 | ||||
-rw-r--r-- | libavcodec/utils.c | 22 |
2 files changed, 25 insertions, 0 deletions
diff --git a/libavcodec/internal.h b/libavcodec/internal.h index cf8bbe5e32..867e36f1df 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -124,6 +124,9 @@ unsigned int avpriv_toupper4(unsigned int x); */ void ff_init_buffer_info(AVCodecContext *s, AVFrame *frame); + +void avpriv_color_frame(AVFrame *frame, const int color[4]); + /** * Remove and free all side data from packet. */ diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 569f2ff6e4..dc664d7d86 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -501,6 +501,28 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic) return 0; } +void avpriv_color_frame(AVFrame *frame, const int c[4]) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); + int p, y, x; + + av_assert0(desc->flags & PIX_FMT_PLANAR); + + for (p = 0; p<desc->nb_components; p++) { + uint8_t *dst = frame->data[p]; + int is_chroma = p == 1 || p == 2; + int bytes = -((-frame->width) >> (is_chroma ? desc->log2_chroma_w : 0)); + for (y = 0; y<-((-frame->height) >> (is_chroma ? desc->log2_chroma_h : 0)); y++){ + if (desc->comp[0].depth_minus1 >= 8) { + for (x = 0; x<bytes; x++) + ((uint16_t*)dst)[x] = c[p]; + }else + memset(dst, c[p], bytes); + dst += frame->linesize[p]; + } + } +} + int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame) { frame->type = FF_BUFFER_TYPE_INTERNAL; |