Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
387d8607
Commit
387d8607
authored
Dec 27, 2011
by
Carl Eugen Hoyos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support decoding yuv442 and yuv421 jpeg images.
Fixes ticket #787.
parent
613cbf31
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
mjpegdec.c
libavcodec/mjpegdec.c
+28
-0
mjpegdec.h
libavcodec/mjpegdec.h
+2
-0
No files found.
libavcodec/mjpegdec.c
View file @
387d8607
...
...
@@ -337,12 +337,19 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
}
assert
(
s
->
nb_components
==
3
);
break
;
case
0x12121100
:
s
->
avctx
->
pix_fmt
=
s
->
cs_itu601
?
PIX_FMT_YUV444P
:
PIX_FMT_YUVJ444P
;
s
->
avctx
->
color_range
=
s
->
cs_itu601
?
AVCOL_RANGE_MPEG
:
AVCOL_RANGE_JPEG
;
s
->
yuv442
=
1
;
break
;
case
0x11000000
:
s
->
avctx
->
pix_fmt
=
PIX_FMT_GRAY8
;
break
;
case
0x12111100
:
case
0x22211100
:
s
->
avctx
->
pix_fmt
=
s
->
cs_itu601
?
PIX_FMT_YUV440P
:
PIX_FMT_YUVJ440P
;
s
->
avctx
->
color_range
=
s
->
cs_itu601
?
AVCOL_RANGE_MPEG
:
AVCOL_RANGE_JPEG
;
s
->
yuv421
=
pix_fmt_id
==
0x22211100
;
break
;
case
0x21111100
:
s
->
avctx
->
pix_fmt
=
s
->
cs_itu601
?
PIX_FMT_YUV422P
:
PIX_FMT_YUVJ422P
;
...
...
@@ -1091,6 +1098,27 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
return
-
1
;
}
}
if
(
s
->
yuv421
)
{
uint8_t
*
line
=
s
->
picture_ptr
->
data
[
2
];
for
(
i
=
0
;
i
<
s
->
height
/
2
;
i
++
)
{
for
(
index
=
s
->
width
-
1
;
index
;
index
--
)
line
[
index
]
=
(
line
[
index
/
2
]
+
line
[(
index
+
1
)
/
2
])
>>
1
;
line
+=
s
->
linesize
[
2
];
}
}
else
if
(
s
->
yuv442
)
{
uint8_t
*
dst
=
&
((
uint8_t
*
)
s
->
picture_ptr
->
data
[
2
])[(
s
->
height
-
1
)
*
s
->
linesize
[
2
]];
for
(
i
=
s
->
height
-
1
;
i
;
i
--
)
{
uint8_t
*
src1
=
&
((
uint8_t
*
)
s
->
picture_ptr
->
data
[
2
])[
i
/
2
*
s
->
linesize
[
2
]];
uint8_t
*
src2
=
&
((
uint8_t
*
)
s
->
picture_ptr
->
data
[
2
])[(
i
+
1
)
/
2
*
s
->
linesize
[
2
]];
if
(
src1
==
src2
)
{
memcpy
(
dst
,
src1
,
s
->
width
);
}
else
{
for
(
index
=
0
;
index
<
s
->
width
;
index
++
)
dst
[
index
]
=
(
src1
[
index
]
+
src2
[
index
])
>>
1
;
}
dst
-=
s
->
linesize
[
2
];
}
}
emms_c
();
return
0
;
out_of_range
:
...
...
libavcodec/mjpegdec.h
View file @
387d8607
...
...
@@ -58,6 +58,8 @@ typedef struct MJpegDecodeContext {
int
ls
;
int
progressive
;
int
rgb
;
int
yuv421
;
int
yuv442
;
int
rct
;
/* standard rct */
int
pegasus_rct
;
/* pegasus reversible colorspace transform */
int
bits
;
/* bits per component */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment