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
2c902045
Commit
2c902045
authored
Jan 12, 2012
by
Carl Eugen Hoyos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix decoding of progressive jpgs with unusual pixel formats.
Fixes ticket #892.
parent
7cbb32e4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
22 deletions
+33
-22
mjpegdec.c
libavcodec/mjpegdec.c
+33
-22
No files found.
libavcodec/mjpegdec.c
View file @
2c902045
...
@@ -219,6 +219,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
...
@@ -219,6 +219,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
int
len
,
nb_components
,
i
,
width
,
height
,
pix_fmt_id
;
int
len
,
nb_components
,
i
,
width
,
height
,
pix_fmt_id
;
s
->
cur_scan
=
0
;
s
->
cur_scan
=
0
;
s
->
upscale_h
=
s
->
upscale_v
=
0
;
/* XXX: verify len field validity */
/* XXX: verify len field validity */
len
=
get_bits
(
&
s
->
gb
,
16
);
len
=
get_bits
(
&
s
->
gb
,
16
);
...
@@ -401,6 +402,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
...
@@ -401,6 +402,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
return
-
1
;
return
-
1
;
}
}
if
(
s
->
ls
)
{
if
(
s
->
ls
)
{
s
->
upscale_h
=
s
->
upscale_v
=
0
;
if
(
s
->
nb_components
>
1
)
if
(
s
->
nb_components
>
1
)
s
->
avctx
->
pix_fmt
=
PIX_FMT_RGB24
;
s
->
avctx
->
pix_fmt
=
PIX_FMT_RGB24
;
else
if
(
s
->
bits
<=
8
)
else
if
(
s
->
bits
<=
8
)
...
@@ -1233,28 +1235,6 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask,
...
@@ -1233,28 +1235,6 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask,
return
-
1
;
return
-
1
;
}
}
}
}
if
(
s
->
upscale_h
)
{
uint8_t
*
line
=
s
->
picture_ptr
->
data
[
s
->
upscale_h
];
for
(
i
=
0
;
i
<
s
->
chroma_height
;
i
++
)
{
for
(
index
=
s
->
width
-
1
;
index
;
index
--
)
line
[
index
]
=
(
line
[
index
/
2
]
+
line
[(
index
+
1
)
/
2
])
>>
1
;
line
+=
s
->
linesize
[
s
->
upscale_h
];
}
}
if
(
s
->
upscale_v
)
{
uint8_t
*
dst
=
&
((
uint8_t
*
)
s
->
picture_ptr
->
data
[
s
->
upscale_v
])[(
s
->
height
-
1
)
*
s
->
linesize
[
s
->
upscale_v
]];
for
(
i
=
s
->
height
-
1
;
i
;
i
--
)
{
uint8_t
*
src1
=
&
((
uint8_t
*
)
s
->
picture_ptr
->
data
[
s
->
upscale_v
])[
i
/
2
*
s
->
linesize
[
s
->
upscale_v
]];
uint8_t
*
src2
=
&
((
uint8_t
*
)
s
->
picture_ptr
->
data
[
s
->
upscale_v
])[(
i
+
1
)
/
2
*
s
->
linesize
[
s
->
upscale_v
]];
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
[
s
->
upscale_v
];
}
}
emms_c
();
emms_c
();
return
0
;
return
0
;
out_of_range:
out_of_range:
...
@@ -1576,6 +1556,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
...
@@ -1576,6 +1556,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
const
uint8_t
*
unescaped_buf_ptr
;
const
uint8_t
*
unescaped_buf_ptr
;
int
unescaped_buf_size
;
int
unescaped_buf_size
;
int
start_code
;
int
start_code
;
int
i
,
index
;
AVFrame
*
picture
=
data
;
AVFrame
*
picture
=
data
;
s
->
got_picture
=
0
;
// picture from previous image can not be reused
s
->
got_picture
=
0
;
// picture from previous image can not be reused
...
@@ -1735,6 +1716,36 @@ eoi_parser:
...
@@ -1735,6 +1716,36 @@ eoi_parser:
av_log
(
avctx
,
AV_LOG_FATAL
,
"No JPEG data found in image
\n
"
);
av_log
(
avctx
,
AV_LOG_FATAL
,
"No JPEG data found in image
\n
"
);
return
-
1
;
return
-
1
;
the_end:
the_end:
if
(
s
->
upscale_h
)
{
uint8_t
*
line
=
s
->
picture_ptr
->
data
[
s
->
upscale_h
];
av_assert0
(
avctx
->
pix_fmt
==
PIX_FMT_YUVJ444P
||
avctx
->
pix_fmt
==
PIX_FMT_YUV444P
||
avctx
->
pix_fmt
==
PIX_FMT_YUVJ440P
||
avctx
->
pix_fmt
==
PIX_FMT_YUV440P
);
for
(
i
=
0
;
i
<
s
->
chroma_height
;
i
++
)
{
for
(
index
=
s
->
width
-
1
;
index
;
index
--
)
line
[
index
]
=
(
line
[
index
/
2
]
+
line
[(
index
+
1
)
/
2
])
>>
1
;
line
+=
s
->
linesize
[
s
->
upscale_h
];
}
}
if
(
s
->
upscale_v
)
{
uint8_t
*
dst
=
&
((
uint8_t
*
)
s
->
picture_ptr
->
data
[
s
->
upscale_v
])[(
s
->
height
-
1
)
*
s
->
linesize
[
s
->
upscale_v
]];
av_assert0
(
avctx
->
pix_fmt
==
PIX_FMT_YUVJ444P
||
avctx
->
pix_fmt
==
PIX_FMT_YUV444P
||
avctx
->
pix_fmt
==
PIX_FMT_YUVJ422P
||
avctx
->
pix_fmt
==
PIX_FMT_YUV422P
);
for
(
i
=
s
->
height
-
1
;
i
;
i
--
)
{
uint8_t
*
src1
=
&
((
uint8_t
*
)
s
->
picture_ptr
->
data
[
s
->
upscale_v
])[
i
/
2
*
s
->
linesize
[
s
->
upscale_v
]];
uint8_t
*
src2
=
&
((
uint8_t
*
)
s
->
picture_ptr
->
data
[
s
->
upscale_v
])[(
i
+
1
)
/
2
*
s
->
linesize
[
s
->
upscale_v
]];
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
[
s
->
upscale_v
];
}
}
av_log
(
avctx
,
AV_LOG_DEBUG
,
"mjpeg decode frame unused %td bytes
\n
"
,
av_log
(
avctx
,
AV_LOG_DEBUG
,
"mjpeg decode frame unused %td bytes
\n
"
,
buf_end
-
buf_ptr
);
buf_end
-
buf_ptr
);
// return buf_end - buf_ptr;
// return buf_end - buf_ptr;
...
...
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