Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
0d75e9fa
Commit
0d75e9fa
authored
Jan 30, 2014
by
Maxim Bublis
Committed by
Rafaël Carré
Jan 31, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codec/jpeg: move some setup in init function
Signed-off-by:
Rafaël Carré
<
funman@videolan.org
>
parent
4329e2a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
52 deletions
+76
-52
modules/codec/jpeg.c
modules/codec/jpeg.c
+76
-52
No files found.
modules/codec/jpeg.c
View file @
0d75e9fa
/*****************************************************************************
* jpeg.c: jpeg decoder module making use of libjpeg.
*****************************************************************************
* Copyright (C) 2013 VLC authors and VideoLAN
* Copyright (C) 2013
-2014
VLC authors and VideoLAN
*
* Authors: Maxim Bublis <b@codemonkey.ru>
*
...
...
@@ -30,18 +30,39 @@
#include <jpeglib.h>
#include <setjmp.h>
/* JPEG_SYS_COMMON_MEMBERS:
* members common to encoder and decoder descriptors
*/
#define JPEG_SYS_COMMON_MEMBERS \
/**@{*/
\
/* libjpeg error handler manager */
\
struct jpeg_error_mgr err; \
\
/* setjmp buffer for internal libjpeg error handling */
\
jmp_buf setjmp_buffer; \
\
vlc_object_t *p_obj; \
\
/**@}*/
\
/*
* jpeg common descriptor
*/
struct
jpeg_sys_t
{
JPEG_SYS_COMMON_MEMBERS
};
typedef
struct
jpeg_sys_t
jpeg_sys_t
;
/*
* jpeg decoder descriptor
*/
struct
decoder_sys_t
{
/* libjpeg error handler manager */
struct
jpeg_error_mgr
err
;
JPEG_SYS_COMMON_MEMBERS
/* setjmp buffer for internal libjpeg error handling */
jmp_buf
setjmp_buffer
;
decoder_t
*
p_dec
;
struct
jpeg_decompress_struct
p_jpeg
;
};
static
int
OpenDecoder
(
vlc_object_t
*
);
...
...
@@ -61,6 +82,29 @@ vlc_module_begin()
add_shortcut
(
"jpeg"
)
vlc_module_end
()
/*
* Exit error handler for libjpeg
*/
static
void
user_error_exit
(
j_common_ptr
p_jpeg
)
{
jpeg_sys_t
*
p_sys
=
(
jpeg_sys_t
*
)
p_jpeg
->
err
;
p_sys
->
err
.
output_message
(
p_jpeg
);
longjmp
(
p_sys
->
setjmp_buffer
,
1
);
}
/*
* Emit message error handler for libjpeg
*/
static
void
user_error_message
(
j_common_ptr
p_jpeg
)
{
char
error_msg
[
JMSG_LENGTH_MAX
];
jpeg_sys_t
*
p_sys
=
(
jpeg_sys_t
*
)
p_jpeg
->
err
;
p_sys
->
err
.
format_message
(
p_jpeg
,
error_msg
);
msg_Err
(
p_sys
->
p_obj
,
"%s"
,
error_msg
);
}
/*
* Probe the decoder and return score
*/
...
...
@@ -74,13 +118,19 @@ static int OpenDecoder(vlc_object_t *p_this)
}
/* Allocate the memory needed to store the decoder's structure */
p_dec
->
p_sys
=
malloc
(
sizeof
(
decoder_sys_t
));
if
(
p_
dec
->
p_
sys
==
NULL
)
decoder_sys_t
*
p_sys
=
malloc
(
sizeof
(
decoder_sys_t
));
if
(
p_sys
==
NULL
)
{
return
VLC_ENOMEM
;
}
p_dec
->
p_sys
->
p_dec
=
p_dec
;
p_dec
->
p_sys
=
p_sys
;
p_sys
->
p_obj
=
p_this
;
p_sys
->
p_jpeg
.
err
=
jpeg_std_error
(
&
p_sys
->
err
);
p_sys
->
err
.
error_exit
=
user_error_exit
;
p_sys
->
err
.
output_message
=
user_error_message
;
/* Set output properties */
p_dec
->
fmt_out
.
i_cat
=
VIDEO_ES
;
...
...
@@ -91,28 +141,6 @@ static int OpenDecoder(vlc_object_t *p_this)
return
VLC_SUCCESS
;
}
/*
* Exit error handler for libjpeg
*/
static
void
user_error_exit
(
j_common_ptr
p_jpeg
)
{
decoder_sys_t
*
p_sys
=
(
decoder_sys_t
*
)
p_jpeg
->
err
;
p_sys
->
err
.
output_message
(
p_jpeg
);
longjmp
(
p_sys
->
setjmp_buffer
,
1
);
}
/*
* Emit message error handler for libjpeg
*/
static
void
user_error_message
(
j_common_ptr
p_jpeg
)
{
char
error_msg
[
JMSG_LENGTH_MAX
];
decoder_sys_t
*
p_sys
=
(
decoder_sys_t
*
)
p_jpeg
->
err
;
p_sys
->
err
.
format_message
(
p_jpeg
,
error_msg
);
msg_Err
(
p_sys
->
p_dec
,
"%s"
,
error_msg
);
}
/*
* This function must be fed with a complete compressed frame.
*/
...
...
@@ -122,7 +150,6 @@ static picture_t *DecodeBlock(decoder_t *p_dec, block_t **pp_block)
block_t
*
p_block
;
picture_t
*
p_pic
=
0
;
struct
jpeg_decompress_struct
p_jpeg
;
JSAMPARRAY
p_row_pointers
=
NULL
;
if
(
!
pp_block
||
!*
pp_block
)
...
...
@@ -139,28 +166,24 @@ static picture_t *DecodeBlock(decoder_t *p_dec, block_t **pp_block)
return
NULL
;
}
p_jpeg
.
err
=
jpeg_std_error
(
&
p_sys
->
err
);
p_sys
->
err
.
error_exit
=
user_error_exit
;
p_sys
->
err
.
output_message
=
user_error_message
;
/* libjpeg longjmp's there in case of error */
if
(
setjmp
(
p_sys
->
setjmp_buffer
))
{
goto
error
;
}
jpeg_create_decompress
(
&
p_jpeg
);
jpeg_mem_src
(
&
p_jpeg
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
jpeg_read_header
(
&
p_jpeg
,
TRUE
);
jpeg_create_decompress
(
&
p_
sys
->
p_
jpeg
);
jpeg_mem_src
(
&
p_
sys
->
p_
jpeg
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
jpeg_read_header
(
&
p_
sys
->
p_
jpeg
,
TRUE
);
p_jpeg
.
out_color_space
=
JCS_RGB
;
p_
sys
->
p_
jpeg
.
out_color_space
=
JCS_RGB
;
jpeg_start_decompress
(
&
p_jpeg
);
jpeg_start_decompress
(
&
p_
sys
->
p_
jpeg
);
/* Set output properties */
p_dec
->
fmt_out
.
i_codec
=
VLC_CODEC_RGB24
;
p_dec
->
fmt_out
.
video
.
i_width
=
p_jpeg
.
output_width
;
p_dec
->
fmt_out
.
video
.
i_height
=
p_jpeg
.
output_height
;
p_dec
->
fmt_out
.
video
.
i_width
=
p_
sys
->
p_
jpeg
.
output_width
;
p_dec
->
fmt_out
.
video
.
i_height
=
p_
sys
->
p_
jpeg
.
output_height
;
p_dec
->
fmt_out
.
video
.
i_sar_num
=
1
;
p_dec
->
fmt_out
.
video
.
i_sar_den
=
1
;
p_dec
->
fmt_out
.
video
.
i_rmask
=
0x000000ff
;
...
...
@@ -175,23 +198,24 @@ static picture_t *DecodeBlock(decoder_t *p_dec, block_t **pp_block)
}
/* Decode picture */
p_row_pointers
=
malloc
(
sizeof
(
JSAMPROW
)
*
p_jpeg
.
output_height
);
p_row_pointers
=
malloc
(
sizeof
(
JSAMPROW
)
*
p_
sys
->
p_
jpeg
.
output_height
);
if
(
!
p_row_pointers
)
{
goto
error
;
}
for
(
unsigned
i
=
0
;
i
<
p_jpeg
.
output_height
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
p_
sys
->
p_
jpeg
.
output_height
;
i
++
)
{
p_row_pointers
[
i
]
=
p_pic
->
p
->
p_pixels
+
p_pic
->
p
->
i_pitch
*
i
;
}
while
(
p_
jpeg
.
output_scanline
<
p_jpeg
.
output_height
)
while
(
p_
sys
->
p_jpeg
.
output_scanline
<
p_sys
->
p_jpeg
.
output_height
)
{
jpeg_read_scanlines
(
&
p_jpeg
,
p_row_pointers
+
p_jpeg
.
output_scanline
,
p_jpeg
.
output_height
-
p_jpeg
.
output_scanline
);
jpeg_read_scanlines
(
&
p_sys
->
p_jpeg
,
p_row_pointers
+
p_sys
->
p_jpeg
.
output_scanline
,
p_sys
->
p_jpeg
.
output_height
-
p_sys
->
p_jpeg
.
output_scanline
);
}
jpeg_finish_decompress
(
&
p_jpeg
);
jpeg_destroy_decompress
(
&
p_jpeg
);
jpeg_finish_decompress
(
&
p_
sys
->
p_
jpeg
);
jpeg_destroy_decompress
(
&
p_
sys
->
p_
jpeg
);
free
(
p_row_pointers
);
p_pic
->
date
=
p_block
->
i_pts
>
VLC_TS_INVALID
?
p_block
->
i_pts
:
p_block
->
i_dts
;
...
...
@@ -203,7 +227,7 @@ static picture_t *DecodeBlock(decoder_t *p_dec, block_t **pp_block)
error:
jpeg_destroy_decompress
(
&
p_jpeg
);
jpeg_destroy_decompress
(
&
p_
sys
->
p_
jpeg
);
free
(
p_row_pointers
);
block_Release
(
p_block
);
...
...
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