mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
mjpegenc_common: check for codec ID before using avctx->priv_data
When coding lossless jpeg the priv context will be pointing to LJpegEncContext rather than MpegEncContext, which the function expects. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
This commit is contained in:
parent
a8b5f37501
commit
2c9be3882a
@ -91,13 +91,17 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
|
|||||||
{
|
{
|
||||||
int i, j, size;
|
int i, j, size;
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
MpegEncContext *s = avctx->priv_data;
|
MpegEncContext *s = NULL;
|
||||||
|
|
||||||
|
/* Since avctx->priv_data will point to LJpegEncContext in this case */
|
||||||
|
if (avctx->codec_id != AV_CODEC_ID_LJPEG)
|
||||||
|
s = avctx->priv_data;
|
||||||
|
|
||||||
if (avctx->codec_id != AV_CODEC_ID_LJPEG) {
|
if (avctx->codec_id != AV_CODEC_ID_LJPEG) {
|
||||||
int matrix_count = 1 + !!memcmp(luma_intra_matrix,
|
int matrix_count = 1 + !!memcmp(luma_intra_matrix,
|
||||||
chroma_intra_matrix,
|
chroma_intra_matrix,
|
||||||
sizeof(luma_intra_matrix[0]) * 64);
|
sizeof(luma_intra_matrix[0]) * 64);
|
||||||
if (s->force_duplicated_matrix)
|
if (s && s->force_duplicated_matrix)
|
||||||
matrix_count = 2;
|
matrix_count = 2;
|
||||||
/* quant matrixes */
|
/* quant matrixes */
|
||||||
put_marker(p, DQT);
|
put_marker(p, DQT);
|
||||||
@ -134,7 +138,7 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
|
|||||||
|
|
||||||
// Only MJPEG can have a variable Huffman variable. All other
|
// Only MJPEG can have a variable Huffman variable. All other
|
||||||
// formats use the default Huffman table.
|
// formats use the default Huffman table.
|
||||||
if (s->out_format == FMT_MJPEG && s->huffman == HUFFMAN_TABLE_OPTIMAL) {
|
if (s && s->huffman == HUFFMAN_TABLE_OPTIMAL) {
|
||||||
size += put_huffman_table(p, 0, 0, s->mjpeg_ctx->bits_dc_luminance,
|
size += put_huffman_table(p, 0, 0, s->mjpeg_ctx->bits_dc_luminance,
|
||||||
s->mjpeg_ctx->val_dc_luminance);
|
s->mjpeg_ctx->val_dc_luminance);
|
||||||
size += put_huffman_table(p, 0, 1, s->mjpeg_ctx->bits_dc_chrominance,
|
size += put_huffman_table(p, 0, 1, s->mjpeg_ctx->bits_dc_chrominance,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user