FFmpeg
Loading...
Searching...
No Matches
libavcodec
bitpacked_dec.c
Go to the documentation of this file.
1
/*
2
* Unpack bit-packed streams to formats supported by FFmpeg
3
* Copyright (c) 2017 Savoir-faire Linux, Inc
4
*
5
* This file is part of FFmpeg.
6
*
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* FFmpeg is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
/* Development sponsored by CBC/Radio-Canada */
23
24
/**
25
* @file
26
* Bitpacked
27
*/
28
29
#include "
avcodec.h
"
30
#include "
bitpacked_dec.h
"
31
#include "
bitpacked_dec_init.h
"
32
#include "
codec_internal.h
"
33
#include "
libavutil/imgutils.h
"
34
#include "
thread.h
"
35
36
/* For this format, it's a simple passthrough */
37
static
int
bitpacked_decode_uyvy422
(
AVCodecContext
*avctx,
AVFrame
*
frame
,
38
const
AVPacket
*avpkt)
39
{
40
int
ret
;
41
42
ret
=
av_image_fill_arrays
(
frame
->data,
frame
->linesize, avpkt->
data
,
43
avctx->
pix_fmt
, avctx->
width
, avctx->
height
, 1);
44
if
(
ret
< 0)
45
return
ret
;
46
if
(
ret
> avpkt->
size
)
47
return
AVERROR_INVALIDDATA
;
48
49
/* there is no need to copy as the data already match
50
* a known pixel format */
51
frame
->buf[0] =
av_buffer_ref
(avpkt->
buf
);
52
if
(!
frame
->buf[0]) {
53
return
AVERROR
(ENOMEM);
54
}
55
56
return
0;
57
}
58
59
static
int
bitpacked_decode_yuv422p10
(
AVCodecContext
*avctx,
AVFrame
*
frame
,
60
const
AVPacket
*avpkt)
61
{
62
struct
BitpackedContext
*bc = avctx->
priv_data
;
63
uint64_t