Commit 2cb656ad authored by James Almer's avatar James Almer

avcodec/mjpegenc: move ff_mjpeg_encode_picture_frame to mjpegenc_common

Fixes compilation of ljpeg encoder if mjpeg and amv encoders are disabled
parent 74fee976
......@@ -40,7 +40,6 @@
#include "jpegtables.h"
#include "mjpegenc_common.h"
#include "mjpeg.h"
#include "mjpegenc.h"
typedef struct LJpegEncContext {
AVClass *class;
......
......@@ -129,54 +129,6 @@ av_cold void ff_mjpeg_encode_close(MpegEncContext *s)
av_freep(&s->mjpeg_ctx);
}
/**
* Encodes and outputs the entire frame in the JPEG format.
*
* @param s The MpegEncContext.
*/
void ff_mjpeg_encode_picture_frame(MpegEncContext *s)
{
int i, nbits, code, table_id;
MJpegContext *m = s->mjpeg_ctx;
uint8_t *huff_size[4] = {m->huff_size_dc_luminance,
m->huff_size_dc_chrominance,
m->huff_size_ac_luminance,
m->huff_size_ac_chrominance};
uint16_t *huff_code[4] = {m->huff_code_dc_luminance,
m->huff_code_dc_chrominance,
m->huff_code_ac_luminance,
m->huff_code_ac_chrominance};
size_t total_bits = 0;
size_t bytes_needed;
s->header_bits = get_bits_diff(s);
// Estimate the total size first
for (i = 0; i < m->huff_ncode; i++) {
table_id = m->huff_buffer[i].table_id;
code = m->huff_buffer[i].code;
nbits = code & 0xf;
total_bits += huff_size[table_id][code] + nbits;
}
bytes_needed = (total_bits + 7) / 8;
ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
for (i = 0; i < m->huff_ncode; i++) {
table_id = m->huff_buffer[i].table_id;
code = m->huff_buffer[i].code;
nbits = code & 0xf;
put_bits(&s->pb, huff_size[table_id][code], huff_code[table_id][code]);
if (nbits != 0) {
put_sbits(&s->pb, nbits, m->huff_buffer[i].mant);
}
}
m->huff_ncode = 0;
s->i_tex_bits = get_bits_diff(s);
}
/**
* Add code and table_id to the JPEG buffer.
*
......
......@@ -105,7 +105,6 @@ static inline void put_marker(PutBitContext *p, enum JpegMarker code)
}
int ff_mjpeg_encode_init(MpegEncContext *s);
void ff_mjpeg_encode_picture_frame(MpegEncContext *s);
void ff_mjpeg_encode_close(MpegEncContext *s);
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]);
......
......@@ -359,6 +359,54 @@ end:
}
}
/**
* Encodes and outputs the entire frame in the JPEG format.
*
* @param s The MpegEncContext.
*/
void ff_mjpeg_encode_picture_frame(MpegEncContext *s)
{
int i, nbits, code, table_id;
MJpegContext *m = s->mjpeg_ctx;
uint8_t *huff_size[4] = {m->huff_size_dc_luminance,
m->huff_size_dc_chrominance,
m->huff_size_ac_luminance,
m->huff_size_ac_chrominance};
uint16_t *huff_code[4] = {m->huff_code_dc_luminance,
m->huff_code_dc_chrominance,
m->huff_code_ac_luminance,
m->huff_code_ac_chrominance};
size_t total_bits = 0;
size_t bytes_needed;
s->header_bits = get_bits_diff(s);
// Estimate the total size first
for (i = 0; i < m->huff_ncode; i++) {
table_id = m->huff_buffer[i].table_id;
code = m->huff_buffer[i].code;
nbits = code & 0xf;
total_bits += huff_size[table_id][code] + nbits;
}
bytes_needed = (total_bits + 7) / 8;
ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
for (i = 0; i < m->huff_ncode; i++) {
table_id = m->huff_buffer[i].table_id;
code = m->huff_buffer[i].code;
nbits = code & 0xf;
put_bits(&s->pb, huff_size[table_id][code], huff_code[table_id][code]);
if (nbits != 0) {
put_sbits(&s->pb, nbits, m->huff_buffer[i].mant);
}
}
m->huff_ncode = 0;
s->i_tex_bits = get_bits_diff(s);
}
void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
{
int size;
......
......@@ -32,6 +32,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
ScanTable *intra_scantable, int pred,
uint16_t luma_intra_matrix[64],
uint16_t chroma_intra_matrix[64]);
void ff_mjpeg_encode_picture_frame(MpegEncContext *s);
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
void ff_mjpeg_escape_FF(PutBitContext *pb, int start);
int ff_mjpeg_encode_stuffing(MpegEncContext *s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment