mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-19 09:02:26 +02:00
Add a function to match a 2 element vector of uint16_t and use it in h263 and svq1
instead of custom and bloated code to find an index into a w/h array. Originally committed as revision 21113 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
aa11ce6568
commit
c46eeae2a8
@ -82,22 +82,6 @@ static const uint8_t wrong_run[102] = {
|
|||||||
19, 2, 1, 34, 35, 36
|
19, 2, 1, 34, 35, 36
|
||||||
};
|
};
|
||||||
|
|
||||||
int h263_get_picture_format(int width, int height)
|
|
||||||
{
|
|
||||||
if (width == 128 && height == 96)
|
|
||||||
return 1;
|
|
||||||
else if (width == 176 && height == 144)
|
|
||||||
return 2;
|
|
||||||
else if (width == 352 && height == 288)
|
|
||||||
return 3;
|
|
||||||
else if (width == 704 && height == 576)
|
|
||||||
return 4;
|
|
||||||
else if (width == 1408 && height == 1152)
|
|
||||||
return 5;
|
|
||||||
else
|
|
||||||
return 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the 4 bit value that specifies the given aspect ratio.
|
* Returns the 4 bit value that specifies the given aspect ratio.
|
||||||
* This may be one of the standard aspect ratios or it specifies
|
* This may be one of the standard aspect ratios or it specifies
|
||||||
@ -156,7 +140,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
|
|||||||
put_bits(&s->pb, 1, 0); /* camera off */
|
put_bits(&s->pb, 1, 0); /* camera off */
|
||||||
put_bits(&s->pb, 1, 0); /* freeze picture release off */
|
put_bits(&s->pb, 1, 0); /* freeze picture release off */
|
||||||
|
|
||||||
format = h263_get_picture_format(s->width, s->height);
|
format = ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format), s->width, s->height);
|
||||||
if (!s->h263_plus) {
|
if (!s->h263_plus) {
|
||||||
/* H.263v1 */
|
/* H.263v1 */
|
||||||
put_bits(&s->pb, 3, format);
|
put_bits(&s->pb, 3, format);
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "dsputil.h"
|
#include "dsputil.h"
|
||||||
#include "mpegvideo.h"
|
#include "mpegvideo.h"
|
||||||
#include "mpegvideo_common.h"
|
#include "mpegvideo_common.h"
|
||||||
|
#include "h263.h"
|
||||||
#include "mjpegenc.h"
|
#include "mjpegenc.h"
|
||||||
#include "msmpeg4.h"
|
#include "msmpeg4.h"
|
||||||
#include "faandct.h"
|
#include "faandct.h"
|
||||||
@ -570,7 +571,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
|
|||||||
break;
|
break;
|
||||||
case CODEC_ID_H263:
|
case CODEC_ID_H263:
|
||||||
if (!CONFIG_H263_ENCODER) return -1;
|
if (!CONFIG_H263_ENCODER) return -1;
|
||||||
if (h263_get_picture_format(s->width, s->height) == 7) {
|
if (ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format), s->width, s->height) == 7) {
|
||||||
av_log(avctx, AV_LOG_INFO, "The specified picture size of %dx%d is not valid for the H.263 codec.\nValid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152. Try H.263+.\n", s->width, s->height);
|
av_log(avctx, AV_LOG_INFO, "The specified picture size of %dx%d is not valid for the H.263 codec.\nValid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152. Try H.263+.\n", s->width, s->height);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "svq1_vlc.h"
|
#include "svq1_vlc.h"
|
||||||
|
|
||||||
/* standard video sizes */
|
/* standard video sizes */
|
||||||
const struct svq1_frame_size ff_svq1_frame_size_table[8] = {
|
const struct svq1_frame_size ff_svq1_frame_size_table[7] = {
|
||||||
{ 160, 120 }, { 128, 96 }, { 176, 144 }, { 352, 288 },
|
{ 160, 120 }, { 128, 96 }, { 176, 144 }, { 352, 288 },
|
||||||
{ 704, 576 }, { 240, 180 }, { 320, 240 }, { -1, -1 }
|
{ 704, 576 }, { 240, 180 }, { 320, 240 }
|
||||||
};
|
};
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
#define SVQ1_BLOCK_INTRA 3
|
#define SVQ1_BLOCK_INTRA 3
|
||||||
|
|
||||||
struct svq1_frame_size {
|
struct svq1_frame_size {
|
||||||
int width;
|
uint16_t width;
|
||||||
int height;
|
uint16_t height;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint16_t ff_svq1_packet_checksum (const uint8_t *data, const int length,
|
uint16_t ff_svq1_packet_checksum (const uint8_t *data, const int length,
|
||||||
@ -59,6 +59,6 @@ extern const uint8_t ff_svq1_inter_multistage_vlc[6][8][2];
|
|||||||
extern const uint16_t ff_svq1_intra_mean_vlc[256][2];
|
extern const uint16_t ff_svq1_intra_mean_vlc[256][2];
|
||||||
extern const uint16_t ff_svq1_inter_mean_vlc[512][2];
|
extern const uint16_t ff_svq1_inter_mean_vlc[512][2];
|
||||||
|
|
||||||
extern const struct svq1_frame_size ff_svq1_frame_size_table[8];
|
extern const struct svq1_frame_size ff_svq1_frame_size_table[7];
|
||||||
|
|
||||||
#endif /* AVCODEC_SVQ1_H */
|
#endif /* AVCODEC_SVQ1_H */
|
||||||
|
@ -94,19 +94,11 @@ static void svq1_write_header(SVQ1Context *s, int frame_type)
|
|||||||
/* output 5 unknown bits (2 + 2 + 1) */
|
/* output 5 unknown bits (2 + 2 + 1) */
|
||||||
put_bits(&s->pb, 5, 2); /* 2 needed by quicktime decoder */
|
put_bits(&s->pb, 5, 2); /* 2 needed by quicktime decoder */
|
||||||
|
|
||||||
for (i = 0; i < 7; i++)
|
i= ff_match_2uint16(ff_svq1_frame_size_table, FF_ARRAY_ELEMS(ff_svq1_frame_size_table), s->frame_width, s->frame_height);
|
||||||
{
|
put_bits(&s->pb, 3, i);
|
||||||
if ((ff_svq1_frame_size_table[i].width == s->frame_width) &&
|
|
||||||
(ff_svq1_frame_size_table[i].height == s->frame_height))
|
|
||||||
{
|
|
||||||
put_bits(&s->pb, 3, i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == 7)
|
if (i == 7)
|
||||||
{
|
{
|
||||||
put_bits(&s->pb, 3, 7);
|
|
||||||
put_bits(&s->pb, 12, s->frame_width);
|
put_bits(&s->pb, 12, s->frame_width);
|
||||||
put_bits(&s->pb, 12, s->frame_height);
|
put_bits(&s->pb, 12, s->frame_height);
|
||||||
}
|
}
|
||||||
|
@ -1200,6 +1200,12 @@ int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){
|
||||||
|
int i;
|
||||||
|
for(i=0; i<size && !(tab[i][0]==a && tab[i][1]==b); i++);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
void av_log_missing_feature(void *avc, const char *feature, int want_sample)
|
void av_log_missing_feature(void *avc, const char *feature, int want_sample)
|
||||||
{
|
{
|
||||||
av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your FFmpeg "
|
av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your FFmpeg "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user